Commit 50fc169c authored by Daniel Teske's avatar Daniel Teske
Browse files

ProjectTree: Change hasBuildTargets to FolderNode::showInSimpleTree



So that the resource node can override it.

Task-number: QTCREATORBUG-11678
Change-Id: Id30d1b99ee23cc18fc29fc99cf0ad7ca919ed527
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent e2760349
......@@ -45,7 +45,7 @@ AutotoolsProjectNode::AutotoolsProjectNode(AutotoolsProject *project, Core::IDoc
{
}
bool AutotoolsProjectNode::hasBuildTargets() const
bool AutotoolsProjectNode::showInSimpleTree() const
{
return true;
}
......
......@@ -57,7 +57,7 @@ class AutotoolsProjectNode : public ProjectExplorer::ProjectNode
public:
AutotoolsProjectNode(AutotoolsProject *project, Core::IDocument *projectFile);
bool hasBuildTargets() const;
bool showInSimpleTree() const;
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const;
bool canAddSubProject(const QString &proFilePath) const;
bool addSubProjects(const QStringList &proFilePaths);
......
......@@ -37,7 +37,7 @@ CMakeProjectNode::CMakeProjectNode(const QString &fileName)
{
}
bool CMakeProjectNode::hasBuildTargets() const
bool CMakeProjectNode::showInSimpleTree() const
{
// TODO
return true;
......
......@@ -41,7 +41,7 @@ class CMakeProjectNode : public ProjectExplorer::ProjectNode
friend class CMakeProject;
public:
CMakeProjectNode(const QString &fileName);
virtual bool hasBuildTargets() const;
virtual bool showInSimpleTree() const;
virtual QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const;
virtual bool canAddSubProject(const QString &proFilePath) const;
......
......@@ -225,7 +225,7 @@ FolderNode *GenericProjectNode::findFolderByName(const QStringList &components,
return 0;
}
bool GenericProjectNode::hasBuildTargets() const
bool GenericProjectNode::showInSimpleTree() const
{
return true;
}
......
......@@ -51,7 +51,7 @@ public:
Core::IDocument *projectFile() const;
QString projectFilePath() const;
bool hasBuildTargets() const;
bool showInSimpleTree() const;
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const;
......
......@@ -175,11 +175,11 @@ FlatModel::FlatModel(SessionNode *rootNode, QObject *parent)
NodesWatcher *watcher = new NodesWatcher(this);
m_rootNode->registerWatcher(watcher);
connect(watcher, SIGNAL(aboutToChangeHasBuildTargets(ProjectExplorer::ProjectNode*)),
this, SLOT(aboutToHasBuildTargetsChanged(ProjectExplorer::ProjectNode*)));
connect(watcher, SIGNAL(aboutToChangeShowInSimpleTree(ProjectExplorer::FolderNode*)),
this, SLOT(aboutToShowInSimpleTreeChanged(ProjectExplorer::FolderNode*)));
connect(watcher, SIGNAL(hasBuildTargetsChanged(ProjectExplorer::ProjectNode*)),
this, SLOT(hasBuildTargetsChanged(ProjectExplorer::ProjectNode*)));
connect(watcher, SIGNAL(showInSimpleTreeChanged(ProjectExplorer::FolderNode*)),
this, SLOT(showInSimpleTreeChanged(ProjectExplorer::FolderNode*)));
connect(watcher, SIGNAL(foldersAboutToBeAdded(FolderNode*,QList<FolderNode*>)),
this, SLOT(foldersAboutToBeAdded(FolderNode*,QList<FolderNode*>)));
......@@ -566,14 +566,9 @@ FolderNode *FlatModel::visibleFolderNode(FolderNode *node) const
bool FlatModel::filter(Node *node) const
{
bool isHidden = false;
if (node->nodeType() == SessionNodeType) {
isHidden = false;
} else if (ProjectNode *projectNode = qobject_cast<ProjectNode*>(node)) {
if (m_filterProjects && projectNode->parentFolderNode() != m_rootNode)
isHidden = !projectNode->hasBuildTargets();
} else if (node->nodeType() == FolderNodeType || node->nodeType() == VirtualFolderNodeType) {
if (FolderNode *folderNode = qobject_cast<FolderNode*>(node)) {
if (m_filterProjects)
isHidden = true;
isHidden = !folderNode->showInSimpleTree();
} else if (FileNode *fileNode = qobject_cast<FileNode*>(node)) {
if (m_filterGeneratedFiles)
isHidden = fileNode->isGenerated();
......@@ -762,7 +757,7 @@ void FlatModel::removed(FolderNode* parentNode, const QList<Node*> &newNodeList)
}
}
void FlatModel::aboutToHasBuildTargetsChanged(ProjectExplorer::ProjectNode* node)
void FlatModel::aboutToShowInSimpleTreeChanged(ProjectExplorer::FolderNode* node)
{
if (!m_filterProjects)
return;
......@@ -777,7 +772,7 @@ void FlatModel::aboutToHasBuildTargetsChanged(ProjectExplorer::ProjectNode* node
m_childNodes.remove(fn);
}
void FlatModel::hasBuildTargetsChanged(ProjectExplorer::ProjectNode *node)
void FlatModel::showInSimpleTreeChanged(ProjectExplorer::FolderNode *node)
{
if (!m_filterProjects)
return;
......
......@@ -78,8 +78,8 @@ public slots:
void setGeneratedFilesFilterEnabled(bool filter);
private slots:
void aboutToHasBuildTargetsChanged(ProjectExplorer::ProjectNode *node);
void hasBuildTargetsChanged(ProjectExplorer::ProjectNode *node);
void aboutToShowInSimpleTreeChanged(ProjectExplorer::FolderNode *node);
void showInSimpleTreeChanged(ProjectExplorer::FolderNode *node);
void foldersAboutToBeAdded(FolderNode *parentFolder, const QList<FolderNode*> &newFolders);
void foldersAdded();
......
......@@ -509,6 +509,23 @@ void FolderNode::removeFolderNodes(const QList<FolderNode*> &subFolders)
emit watcher->foldersRemoved();
}
void FolderNode::aboutToChangeShowInSimpleTree()
{
foreach (NodesWatcher *watcher, projectNode()->watchers())
emit watcher->aboutToChangeShowInSimpleTree(this);
}
void FolderNode::showInSimpleTreeChanged()
{
foreach (NodesWatcher *watcher, projectNode()->watchers())
emit watcher->showInSimpleTreeChanged(this);
}
bool FolderNode::showInSimpleTree() const
{
return false;
}
/*!
\class ProjectExplorer::VirtualFolderNode
......@@ -572,18 +589,6 @@ 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 &)
*/
......@@ -790,6 +795,11 @@ void SessionNode::accept(NodesVisitor *visitor)
project->accept(visitor);
}
bool SessionNode::showInSimpleTree() const
{
return true;
}
QList<ProjectNode*> SessionNode::projectNodes() const
{
return m_projectNodes;
......
......@@ -191,12 +191,19 @@ public:
virtual AddNewInformation addNewInformation(const QStringList &files, Node *context) const;
// determines if node will be shown in the flat view, by default folder and projects aren't shown
void aboutToChangeShowInSimpleTree();
void showInSimpleTreeChanged();
virtual bool showInSimpleTree() const;
void addFileNodes(const QList<FileNode*> &files);
void removeFileNodes(const QList<FileNode*> &files);
void addFolderNodes(const QList<FolderNode*> &subFolders);
void removeFolderNodes(const QList<FolderNode*> &subFolders);
protected:
QList<FolderNode*> m_subFolderNodes;
QList<FileNode*> m_fileNodes;
......@@ -231,12 +238,6 @@ public:
// all subFolders that are projects
QList<ProjectNode*> subProjectNodes() const;
// 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 bool canAddSubProject(const QString &proFilePath) const = 0;
virtual bool addSubProjects(const QStringList &proFilePaths) = 0;
......@@ -323,8 +324,8 @@ signals:
void nodeUpdated(ProjectExplorer::Node *node);
// projects
void aboutToChangeHasBuildTargets(ProjectExplorer::ProjectNode*);
void hasBuildTargetsChanged(ProjectExplorer::ProjectNode *node);
void aboutToChangeShowInSimpleTree(ProjectExplorer::FolderNode*);
void showInSimpleTreeChanged(ProjectExplorer::FolderNode *node);
// folders & projects
void foldersAboutToBeAdded(FolderNode *parentFolder,
......
......@@ -250,7 +250,7 @@ QbsBaseProjectNode::QbsBaseProjectNode(const QString &path) :
ProjectExplorer::ProjectNode(path)
{ }
bool QbsBaseProjectNode::hasBuildTargets() const
bool QbsBaseProjectNode::showInSimpleTree() const
{
return false;
}
......@@ -493,7 +493,7 @@ bool QbsProductNode::isEnabled() const
return m_qbsProductData.isEnabled();
}
bool QbsProductNode::hasBuildTargets() const
bool QbsProductNode::showInSimpleTree() const
{
return true;
}
......@@ -666,6 +666,11 @@ const qbs::ProjectData QbsProjectNode::qbsProjectData() const
return m_qbsProjectData;
}
bool QbsProjectNode::showInSimpleTree() const
{
return true;
}
void QbsProjectNode::ctor()
{
if (m_projectIcon.isNull())
......
......@@ -74,7 +74,7 @@ class QbsBaseProjectNode : public ProjectExplorer::ProjectNode
public:
explicit QbsBaseProjectNode(const QString &path);
bool hasBuildTargets() const;
bool showInSimpleTree() const;
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const;
......@@ -138,7 +138,7 @@ public:
explicit QbsProductNode(const qbs::ProductData &prd);
bool isEnabled() const;
bool hasBuildTargets() const;
bool showInSimpleTree() const;
void setQbsProductData(const qbs::ProductData prd);
const qbs::ProductData qbsProductData() const { return m_qbsProductData; }
......
......@@ -1567,9 +1567,9 @@ bool QmakeProFileNode::isParent(QmakeProFileNode *node)
return false;
}
bool QmakeProFileNode::hasBuildTargets() const
bool QmakeProFileNode::showInSimpleTree() const
{
return hasBuildTargets(projectType());
return showInSimpleTree(projectType()) || m_project->rootProjectNode() == this;
}
ProjectExplorer::FolderNode::AddNewInformation QmakeProFileNode::addNewInformation(const QStringList &files, Node *context) const
......@@ -1578,7 +1578,7 @@ ProjectExplorer::FolderNode::AddNewInformation QmakeProFileNode::addNewInformati
return AddNewInformation(QFileInfo(path()).fileName(), context == this ? 120 : 100);
}
bool QmakeProFileNode::hasBuildTargets(QmakeProjectType projectType) const
bool QmakeProFileNode::showInSimpleTree(QmakeProjectType projectType) const
{
return (projectType == ApplicationTemplate || projectType == LibraryTemplate);
}
......@@ -1788,15 +1788,15 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async)
removeProjectNodes(subProjectNodes());
removeFolderNodes(subFolderNodes());
bool changesHasBuildTargets = hasBuildTargets() ^ hasBuildTargets(projectType);
bool changesShowInSimpleTree = showInSimpleTree() ^ showInSimpleTree(projectType);
if (changesHasBuildTargets)
aboutToChangeHasBuildTargets();
if (changesShowInSimpleTree)
aboutToChangeShowInSimpleTree();
m_projectType = projectType;
if (changesHasBuildTargets)
hasBuildTargetsChanged();
if (changesShowInSimpleTree)
showInSimpleTreeChanged();
// 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
......
......@@ -147,7 +147,7 @@ public:
// ProjectNode interface
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const;
bool hasBuildTargets() const { return false; }
bool showInSimpleTree() const { return false; }
bool canAddSubProject(const QString &proFilePath) const;
......@@ -366,7 +366,7 @@ public:
bool isParent(QmakeProFileNode *node);
bool hasBuildTargets() const;
bool showInSimpleTree() const;
AddNewInformation addNewInformation(const QStringList &files, Node *context) const;
......@@ -404,7 +404,7 @@ public:
bool validParse() const;
bool parseInProgress() const;
bool hasBuildTargets(QmakeProjectType projectType) const;
bool showInSimpleTree(QmakeProjectType projectType) const;
bool isDebugAndRelease() const;
void setParseInProgress(bool b);
......
......@@ -164,7 +164,7 @@ ProjectExplorer::FolderNode *QmlProjectNode::findOrCreateFolderByName(const QStr
return findOrCreateFolderByName(components, components.length());
}
bool QmlProjectNode::hasBuildTargets() const
bool QmlProjectNode::showInSimpleTree() const
{
return true;
}
......
......@@ -52,7 +52,7 @@ public:
Core::IDocument *projectFile() const;
QString projectFilePath() const;
virtual bool hasBuildTargets() const;
virtual bool showInSimpleTree() const;
virtual QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const;
......
......@@ -257,6 +257,11 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceTopLevelNode::addNewInfor
return AddNewInformation(name, p);
}
bool ResourceTopLevelNode::showInSimpleTree() const
{
return true;
}
ResourceFolderNode::ResourceFolderNode(const QString &prefix, const QString &lang, ResourceTopLevelNode *parent)
: ProjectExplorer::FolderNode(parent->path() + QLatin1Char('/') + prefix),
// TOOD Why add existing directory doesn't work
......
......@@ -60,6 +60,7 @@ public:
bool removePrefix(const QString &prefix, const QString &lang);
AddNewInformation addNewInformation(const QStringList &files, Node *context) const;
bool showInSimpleTree() const;
private:
Internal::ResourceFileWatcher *m_document;
......
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