Commit 58214f09 authored by hjk's avatar hjk
Browse files

QbsProjectManager: Code cosmetics



Remove unused QbsProductNode::findGroupNode and productPath.
Also, simplify setup of static icons.

Change-Id: Ibfaa1398eefcf3f764173d5b37aa4382b68976c9
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent ebae6426
......@@ -42,6 +42,7 @@
#include <QtDebug>
#include <QDir>
#include <QIcon>
#include <QStyle>
// ----------------------------------------------------------------------
......@@ -64,10 +65,6 @@ static QIcon generateIcon(const QString &overlay)
namespace QbsProjectManager {
namespace Internal {
QIcon QbsGroupNode::m_groupIcon;
QIcon QbsProjectNode::m_projectIcon;
QIcon QbsProductNode::m_productIcon;
static QbsProjectNode *parentQbsProjectNode(ProjectExplorer::Node *node)
{
for (ProjectExplorer::FolderNode *pn = node->managingProject(); pn; pn = pn->parentProjectNode()) {
......@@ -263,9 +260,8 @@ QString QbsFileNode::displayName() const
QbsFolderNode::QbsFolderNode(const Utils::FileName &folderPath, ProjectExplorer::NodeType nodeType,
const QString &displayName, bool isGeneratedFilesFolder)
: ProjectExplorer::FolderNode(folderPath, nodeType, displayName),
m_isGeneratedFilesFolder(isGeneratedFilesFolder)
const QString &displayName)
: ProjectExplorer::FolderNode(folderPath, nodeType, displayName)
{
}
......@@ -300,10 +296,8 @@ QList<ProjectExplorer::ProjectAction> QbsBaseProjectNode::supportedActions(Proje
QbsGroupNode::QbsGroupNode(const qbs::GroupData &grp, const QString &productPath) :
QbsBaseProjectNode(Utils::FileName())
{
if (m_groupIcon.isNull())
m_groupIcon = QIcon(QString::fromLatin1(Constants::QBS_GROUP_ICON));
setIcon(m_groupIcon);
static QIcon groupIcon = QIcon(QString(Constants::QBS_GROUP_ICON));
setIcon(groupIcon);
m_productPath = productPath;
m_qbsGroupData = grp;
......@@ -379,10 +373,8 @@ QbsProductNode::QbsProductNode(const qbs::ProductData &prd) :
QbsBaseProjectNode(Utils::FileName::fromString(prd.location().filePath())),
m_qbsProductData(prd)
{
if (m_productIcon.isNull())
m_productIcon = generateIcon(QString::fromLatin1(Constants::QBS_PRODUCT_OVERLAY_ICON));
setIcon(m_productIcon);
static QIcon productIcon = generateIcon(QString(Constants::QBS_PRODUCT_OVERLAY_ICON));
setIcon(productIcon);
}
bool QbsProductNode::showInSimpleTree() const
......@@ -464,16 +456,6 @@ QList<ProjectExplorer::RunConfiguration *> QbsProductNode::runConfigurations() c
return result;
}
QbsGroupNode *QbsProductNode::findGroupNode(const QString &name)
{
for (ProjectExplorer::Node *n : nodes()) {
if (QbsGroupNode *qn = dynamic_cast<QbsGroupNode *>(n))
if (qn->qbsGroupData().name() == name)
return qn;
}
return 0;
}
// --------------------------------------------------------------------
// QbsProjectNode:
// --------------------------------------------------------------------
......@@ -481,15 +463,8 @@ QbsGroupNode *QbsProductNode::findGroupNode(const QString &name)
QbsProjectNode::QbsProjectNode(const Utils::FileName &projectDirectory) :
QbsBaseProjectNode(projectDirectory)
{
if (m_projectIcon.isNull())
m_projectIcon = generateIcon(QString::fromLatin1(ProjectExplorer::Constants::FILEOVERLAY_QT));
setIcon(m_projectIcon);
}
QbsProjectNode::~QbsProjectNode()
{
// do not delete m_project
static QIcon projectIcon = generateIcon(QString(ProjectExplorer::Constants::FILEOVERLAY_QT));
setIcon(projectIcon);
}
QbsProject *QbsProjectNode::project() const
......
......@@ -29,15 +29,11 @@
#include <qbs.h>
#include <QIcon>
namespace QbsProjectManager {
namespace Internal {
class FileTreeNode;
class QbsNodeTreeBuilder;
class QbsProject;
class QbsProjectFile;
// ----------------------------------------------------------------------
// QbsFileNode:
......@@ -56,14 +52,10 @@ class QbsFolderNode : public ProjectExplorer::FolderNode
{
public:
QbsFolderNode(const Utils::FileName &folderPath, ProjectExplorer::NodeType nodeType,
const QString &displayName, bool isGeneratedFilesFolder);
bool isGeneratedFilesFolder() const { return m_isGeneratedFilesFolder; }
const QString &displayName);
private:
QList<ProjectExplorer::ProjectAction> supportedActions(ProjectExplorer::Node *node) const override;
const bool m_isGeneratedFilesFolder;
};
// ---------------------------------------------------------------------------
......@@ -100,13 +92,9 @@ public:
qbs::GroupData qbsGroupData() const { return m_qbsGroupData; }
QString productPath() const;
private:
qbs::GroupData m_qbsGroupData;
QString m_productPath;
static QIcon m_groupIcon;
};
// --------------------------------------------------------------------
......@@ -129,10 +117,7 @@ public:
QList<ProjectExplorer::RunConfiguration *> runConfigurations() const override;
private:
QbsGroupNode *findGroupNode(const QString &name);
const qbs::ProductData m_qbsProductData;
static QIcon m_productIcon;
};
// ---------------------------------------------------------------------------
......@@ -143,18 +128,15 @@ class QbsProjectNode : public QbsBaseProjectNode
{
public:
explicit QbsProjectNode(const Utils::FileName &projectDirectory);
~QbsProjectNode() override;
virtual QbsProject *project() const;
const qbs::Project qbsProject() const;
const qbs::ProjectData qbsProjectData() const { return m_projectData; }
bool showInSimpleTree() const override;
void setProjectData(const qbs::ProjectData &data);
void setProjectData(const qbs::ProjectData &data); // FIXME: Needed?
private:
static QIcon m_projectIcon;
qbs::ProjectData m_projectData;
friend class QbsNodeTreeBuilder;
......
......@@ -148,6 +148,8 @@ void setupProjectNode(QbsProjectManager::Internal::QbsProjectNode *node, const q
node->setDisplayName(prjData.name());
else
node->setDisplayName(node->project()->displayName());
node->setProjectData(prjData);
}
QSet<QString> referencedBuildSystemFiles(const qbs::ProjectData &data)
......
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