forked from qt-creator/qt-creator
ProjectTree: Decouple ProjectTree from Projects
Make sure the ProjectTree gets its data exclusively from the Session and the SessionNode it holds. Change-Id: Ic44e1364adf36077018edc972e18815d7f972922 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -124,7 +124,7 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const
|
|||||||
case Qt::FontRole: {
|
case Qt::FontRole: {
|
||||||
QFont font;
|
QFont font;
|
||||||
if (Project *project = SessionManager::startupProject()) {
|
if (Project *project = SessionManager::startupProject()) {
|
||||||
if (node == project->rootProjectNode())
|
if (node == SessionManager::nodeForProject(project))
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
}
|
}
|
||||||
result = font;
|
result = font;
|
||||||
@@ -227,7 +227,7 @@ ExpandData FlatModel::expandDataForNode(const Node *node) const
|
|||||||
|
|
||||||
void FlatModel::handleProjectAdded(Project *project)
|
void FlatModel::handleProjectAdded(Project *project)
|
||||||
{
|
{
|
||||||
Node *node = project->rootProjectNode();
|
Node *node = SessionManager::nodeForProject(project);
|
||||||
m_toExpand.insert(expandDataForNode(node));
|
m_toExpand.insert(expandDataForNode(node));
|
||||||
if (WrapperNode *wrapper = wrapperForNode(node)) {
|
if (WrapperNode *wrapper = wrapperForNode(node)) {
|
||||||
wrapper->forFirstLevelChildren([this](WrapperNode *child) {
|
wrapper->forFirstLevelChildren([this](WrapperNode *child) {
|
||||||
|
@@ -680,6 +680,15 @@ Project *SessionManager::projectForNode(Node *node)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node *SessionManager::nodeForProject(Project *project)
|
||||||
|
{
|
||||||
|
for (const QPair<Project *,ProjectNode*> &pair : d->m_projects) {
|
||||||
|
if (pair.first == project)
|
||||||
|
return pair.second;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Project *SessionManager::projectForFile(const Utils::FileName &fileName)
|
Project *SessionManager::projectForFile(const Utils::FileName &fileName)
|
||||||
{
|
{
|
||||||
const QList<Project *> &projectList = projects();
|
const QList<Project *> &projectList = projects();
|
||||||
|
@@ -116,6 +116,7 @@ public:
|
|||||||
static SessionNode *sessionNode();
|
static SessionNode *sessionNode();
|
||||||
|
|
||||||
static Project *projectForNode(Node *node);
|
static Project *projectForNode(Node *node);
|
||||||
|
static Node *nodeForProject(Project *project);
|
||||||
static Node *nodeForFile(const Utils::FileName &fileName);
|
static Node *nodeForFile(const Utils::FileName &fileName);
|
||||||
static Project *projectForFile(const Utils::FileName &fileName);
|
static Project *projectForFile(const Utils::FileName &fileName);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user