Commit bdc0e292 authored by dt's avatar dt
Browse files

FlatModel: The simplified tree did not react to hasBuildTarget changes

Task-Nr: QTCREATORBUG-3014
Task-Nr: QTCREATORBUG-2821
parent 1b1da8ae
......@@ -145,6 +145,12 @@ FlatModel::FlatModel(SessionNode *rootNode, QObject *parent)
NodesWatcher *watcher = new NodesWatcher(this);
m_rootNode->registerWatcher(watcher);
connect(watcher, SIGNAL(aboutToHasBuildTargetsChanged(ProjectExplorer::ProjectNode*)),
this, SLOT(aboutToHasBuildTargetsChanged(ProjectExplorer::ProjectNode*)));
connect(watcher, SIGNAL(hasBuildTargetsChanged(ProjectExplorer::ProjectNode*)),
this, SLOT(hasBuildTargetsChanged(ProjectExplorer::ProjectNode*)));
connect(watcher, SIGNAL(foldersAboutToBeAdded(FolderNode *, const QList<FolderNode*> &)),
this, SLOT(foldersAboutToBeAdded(FolderNode *, const QList<FolderNode*> &)));
connect(watcher, SIGNAL(foldersAdded()),
......@@ -508,7 +514,6 @@ bool FlatModel::filter(Node *node) const
if (m_filterGeneratedFiles)
isHidden = fileNode->isGenerated();
}
return isHidden;
}
......@@ -694,6 +699,31 @@ void FlatModel::removed(FolderNode* parentNode, const QList<Node*> &newNodeList)
}
}
void FlatModel::aboutToHasBuildTargetsChanged(ProjectExplorer::ProjectNode* node)
{
if (!m_filterProjects)
return;
FolderNode *folder = visibleFolderNode(node->parentFolderNode());
QList<Node *> newNodeList = childNodes(folder, QSet<Node *>() << node);
removed(folder, newNodeList);
QList<Node *> staleFolders;
recursiveAddFolderNodesImpl(node, &staleFolders);
foreach (Node *n, staleFolders)
if (FolderNode *fn = qobject_cast<FolderNode *>(n))
m_childNodes.remove(fn);
}
void FlatModel::hasBuildTargetsChanged(ProjectExplorer::ProjectNode *node)
{
if (!m_filterProjects)
return;
// we are only interested if we filter
FolderNode *folder = visibleFolderNode(node->parentFolderNode());
QList<Node *> newNodeList = childNodes(folder);
added(folder, newNodeList);
}
void FlatModel::foldersAboutToBeAdded(FolderNode *parentFolder, const QList<FolderNode*> &newFolders)
{
Q_UNUSED(newFolders)
......
......@@ -78,6 +78,8 @@ public slots:
void setGeneratedFilesFilterEnabled(bool filter);
private slots:
void aboutToHasBuildTargetsChanged(ProjectExplorer::ProjectNode *node);
void hasBuildTargetsChanged(ProjectExplorer::ProjectNode *node);
void foldersAboutToBeAdded(FolderNode *parentFolder, const QList<FolderNode*> &newFolders);
void foldersAdded();
......
......@@ -241,6 +241,18 @@ QList<ProjectNode*> ProjectNode::subProjectNodes() const
return m_subProjectNodes;
}
void ProjectNode::aboutToChangeHasBuildTargets()
{
foreach (NodesWatcher *watcher, watchers())
emit watcher->aboutToChangeHasBuildTargets(this);
}
void ProjectNode::hasBuildTargetsChanged()
{
foreach (NodesWatcher *watcher, watchers())
emit watcher->hasBuildTargetsChanged(this);
}
/*!
\function bool ProjectNode::addSubProjects(const QStringList &)
*/
......
......@@ -178,6 +178,8 @@ public:
// determines if the project will be shown in the flat view
// TODO find a better name
void aboutToChangeHasBuildTargets();
void hasBuildTargetsChanged();
virtual bool hasBuildTargets() const = 0;
virtual QList<ProjectAction> supportedActions(Node *node) const = 0;
......@@ -270,6 +272,10 @@ public:
explicit NodesWatcher(QObject *parent = 0);
signals:
// projects
void aboutToChangeHasBuildTargets(ProjectExplorer::ProjectNode*);
void hasBuildTargetsChanged(ProjectExplorer::ProjectNode *node);
// folders & projects
void foldersAboutToBeAdded(FolderNode *parentFolder,
const QList<FolderNode*> &newFolders);
......
......@@ -1296,7 +1296,12 @@ void Qt4ProFileNode::buildStateChanged(ProjectExplorer::Project *project)
bool Qt4ProFileNode::hasBuildTargets() const
{
return (projectType() == ApplicationTemplate) || (projectType() == LibraryTemplate);
return hasBuildTargets(projectType());
}
bool Qt4ProFileNode::hasBuildTargets(Qt4ProjectType projectType) const
{
return (projectType == ApplicationTemplate || projectType == LibraryTemplate);
}
Qt4ProjectType Qt4ProFileNode::projectType() const
......@@ -1476,7 +1481,16 @@ void Qt4ProFileNode::applyEvaluate(bool parseResult, bool async)
Qt4ProjectType oldType = m_projectType;
// probably all subfiles/projects have changed anyway ...
clear();
bool changesHasBuildTargets = hasBuildTargets() xor hasBuildTargets(projectType);
if (changesHasBuildTargets)
aboutToChangeHasBuildTargets();
m_projectType = projectType;
if (changesHasBuildTargets)
hasBuildTargetsChanged();
// really emit here? or at the end? Nobody is connected to this signal at the moment
// so we kind of can ignore that question for now
foreach (NodesWatcher *watcher, watchers())
......
......@@ -303,6 +303,7 @@ public:
bool validParse() const;
bool hasBuildTargets(Qt4ProjectType projectType) const;
public slots:
void asyncUpdate();
......
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