forked from qt-creator/qt-creator
Allow for disabled nodes in Projects view
Change-Id: I8b9a2666c8efdc5981adfe6a3a032884a6e50d2a Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -63,7 +63,8 @@ public:
|
|||||||
// Roles to be implemented by all models that are exported via model()
|
// Roles to be implemented by all models that are exported via model()
|
||||||
enum ModelRoles {
|
enum ModelRoles {
|
||||||
// Absolute file path
|
// Absolute file path
|
||||||
FilePathRole = QFileSystemModel::FilePathRole
|
FilePathRole = QFileSystemModel::FilePathRole,
|
||||||
|
EnabledRole
|
||||||
};
|
};
|
||||||
|
|
||||||
Project();
|
Project();
|
||||||
|
@@ -197,6 +197,9 @@ FlatModel::FlatModel(SessionNode *rootNode, QObject *parent)
|
|||||||
this, SLOT(filesAboutToBeRemoved(FolderNode*,QList<FileNode*>)));
|
this, SLOT(filesAboutToBeRemoved(FolderNode*,QList<FileNode*>)));
|
||||||
connect(watcher, SIGNAL(filesRemoved()),
|
connect(watcher, SIGNAL(filesRemoved()),
|
||||||
this, SLOT(filesRemoved()));
|
this, SLOT(filesRemoved()));
|
||||||
|
|
||||||
|
connect(watcher, SIGNAL(nodeUpdated(ProjectExplorer::Node*)),
|
||||||
|
this, SLOT(nodeUpdated(ProjectExplorer::Node*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex FlatModel::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex FlatModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
@@ -296,6 +299,10 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const
|
|||||||
result = node->path();
|
result = node->path();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ProjectExplorer::Project::EnabledRole: {
|
||||||
|
result = node->isEnabled();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -847,6 +854,12 @@ void FlatModel::filesRemoved()
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlatModel::nodeUpdated(Node *node)
|
||||||
|
{
|
||||||
|
QModelIndex idx = indexForNode(node);
|
||||||
|
emit dataChanged(idx, idx);
|
||||||
|
}
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
@@ -93,6 +93,8 @@ private slots:
|
|||||||
void filesAboutToBeRemoved(FolderNode *folder, const QList<FileNode*> &staleFiles);
|
void filesAboutToBeRemoved(FolderNode *folder, const QList<FileNode*> &staleFiles);
|
||||||
void filesRemoved();
|
void filesRemoved();
|
||||||
|
|
||||||
|
void nodeUpdated(ProjectExplorer::Node *node);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void added(FolderNode* folderNode, const QList<Node*> &newNodeList);
|
void added(FolderNode* folderNode, const QList<Node*> &newNodeList);
|
||||||
void removed(FolderNode* parentNode, const QList<Node*> &newNodeList);
|
void removed(FolderNode* parentNode, const QList<Node*> &newNodeList);
|
||||||
|
@@ -117,6 +117,11 @@ QString Node::tooltip() const
|
|||||||
return QDir::toNativeSeparators(path());
|
return QDir::toNativeSeparators(path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Node::isEnabled() const
|
||||||
|
{
|
||||||
|
return parentFolderNode()->isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
void Node::setNodeType(NodeType type)
|
void Node::setNodeType(NodeType type)
|
||||||
{
|
{
|
||||||
m_nodeType = type;
|
m_nodeType = type;
|
||||||
@@ -127,6 +132,12 @@ void Node::setProjectNode(ProjectNode *project)
|
|||||||
m_projectNode = project;
|
m_projectNode = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::emitNodeUpdated()
|
||||||
|
{
|
||||||
|
foreach (NodesWatcher *watcher, projectNode()->watchers())
|
||||||
|
emit watcher->nodeUpdated(this);
|
||||||
|
}
|
||||||
|
|
||||||
void Node::setParentFolderNode(FolderNode *parentFolder)
|
void Node::setParentFolderNode(FolderNode *parentFolder)
|
||||||
{
|
{
|
||||||
m_folderNode = parentFolder;
|
m_folderNode = parentFolder;
|
||||||
|
@@ -88,6 +88,7 @@ public:
|
|||||||
virtual QString displayName() const;
|
virtual QString displayName() const;
|
||||||
virtual QString vcsTopic() const;
|
virtual QString vcsTopic() const;
|
||||||
virtual QString tooltip() const;
|
virtual QString tooltip() const;
|
||||||
|
virtual bool isEnabled() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Node(NodeType nodeType, const QString &path);
|
Node(NodeType nodeType, const QString &path);
|
||||||
@@ -96,6 +97,8 @@ protected:
|
|||||||
void setProjectNode(ProjectNode *project);
|
void setProjectNode(ProjectNode *project);
|
||||||
void setParentFolderNode(FolderNode *parentFolder);
|
void setParentFolderNode(FolderNode *parentFolder);
|
||||||
|
|
||||||
|
void emitNodeUpdated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NodeType m_nodeType;
|
NodeType m_nodeType;
|
||||||
ProjectNode *m_projectNode;
|
ProjectNode *m_projectNode;
|
||||||
@@ -228,6 +231,8 @@ public:
|
|||||||
|
|
||||||
void accept(NodesVisitor *visitor);
|
void accept(NodesVisitor *visitor);
|
||||||
|
|
||||||
|
bool isEnabled() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// this is just the in-memory representation, a subclass
|
// this is just the in-memory representation, a subclass
|
||||||
// will add the persistent stuff
|
// will add the persistent stuff
|
||||||
@@ -270,6 +275,8 @@ public:
|
|||||||
|
|
||||||
void accept(NodesVisitor *visitor);
|
void accept(NodesVisitor *visitor);
|
||||||
|
|
||||||
|
bool isEnabled() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addProjectNodes(const QList<ProjectNode*> &projectNodes);
|
void addProjectNodes(const QList<ProjectNode*> &projectNodes);
|
||||||
void removeProjectNodes(const QList<ProjectNode*> &projectNodes);
|
void removeProjectNodes(const QList<ProjectNode*> &projectNodes);
|
||||||
@@ -289,6 +296,11 @@ public:
|
|||||||
explicit NodesWatcher(QObject *parent = 0);
|
explicit NodesWatcher(QObject *parent = 0);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
// everything
|
||||||
|
|
||||||
|
// Emited whenever the model needs to send a update signal.
|
||||||
|
void nodeUpdated(ProjectExplorer::Node *node);
|
||||||
|
|
||||||
// projects
|
// projects
|
||||||
void aboutToChangeHasBuildTargets(ProjectExplorer::ProjectNode*);
|
void aboutToChangeHasBuildTargets(ProjectExplorer::ProjectNode*);
|
||||||
void hasBuildTargetsChanged(ProjectExplorer::ProjectNode *node);
|
void hasBuildTargetsChanged(ProjectExplorer::ProjectNode *node);
|
||||||
@@ -316,6 +328,7 @@ private:
|
|||||||
// let project & session emit signals
|
// let project & session emit signals
|
||||||
friend class ProjectNode;
|
friend class ProjectNode;
|
||||||
friend class SessionNode;
|
friend class SessionNode;
|
||||||
|
friend class Node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -49,6 +49,7 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
@@ -62,6 +63,22 @@ using namespace ProjectExplorer;
|
|||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
class ProjectTreeItemDelegate : public QStyledItemDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProjectTreeItemDelegate(QObject *parent) : QStyledItemDelegate(parent)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
QStyleOptionViewItem opt = option;
|
||||||
|
if (!index.data(ProjectExplorer::Project::EnabledRole).toBool())
|
||||||
|
opt.state &= ~QStyle::State_Enabled;
|
||||||
|
QStyledItemDelegate::paint(painter, opt, index);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +132,7 @@ ProjectTreeWidget::ProjectTreeWidget(QWidget *parent)
|
|||||||
|
|
||||||
m_view = new ProjectTreeView;
|
m_view = new ProjectTreeView;
|
||||||
m_view->setModel(m_model);
|
m_view->setModel(m_model);
|
||||||
|
m_view->setItemDelegate(new ProjectTreeItemDelegate(this));
|
||||||
setFocusProxy(m_view);
|
setFocusProxy(m_view);
|
||||||
initView();
|
initView();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user