forked from qt-creator/qt-creator
ProjectExplorer: Fix Project::displayName changes
The only project manager that actually sometimes changes the displayname is the cmake project manager. And that one failed to emit the right signal. And since the signal was never emitted a few places handled the signal wrongly. Change-Id: I4aa75dc3032efe49263143dbadb7585a378b9be9 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -383,6 +383,7 @@ bool CMakeProject::parseCMakeLists()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit displayNameChanged();
|
||||||
emit buildTargetsChanged();
|
emit buildTargetsChanged();
|
||||||
emit fileListChanged();
|
emit fileListChanged();
|
||||||
|
|
||||||
|
@@ -122,6 +122,25 @@ int DoubleTabWidget::currentSubIndex() const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList DoubleTabWidget::subTabs(int index) const
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < m_tabs.size())
|
||||||
|
return m_tabs.at(index).subTabs;
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoubleTabWidget::setCurrentIndex(int index, int subIndex)
|
||||||
|
{
|
||||||
|
Q_ASSERT(index < m_tabs.size());
|
||||||
|
if (index == m_currentIndex
|
||||||
|
&& m_tabs.at(m_currentIndex).currentSubTab == subIndex)
|
||||||
|
return;
|
||||||
|
m_currentIndex = index;
|
||||||
|
m_tabs[m_currentIndex].currentSubTab = subIndex;
|
||||||
|
emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void DoubleTabWidget::setTitle(const QString &title)
|
void DoubleTabWidget::setTitle(const QString &title)
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
|
@@ -56,9 +56,12 @@ public:
|
|||||||
|
|
||||||
int currentIndex() const;
|
int currentIndex() const;
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
|
void setCurrentIndex(int index, int subIndex);
|
||||||
|
|
||||||
int currentSubIndex() const;
|
int currentSubIndex() const;
|
||||||
|
|
||||||
|
QStringList subTabs(int index) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentIndexChanged(int index, int subIndex);
|
void currentIndexChanged(int index, int subIndex);
|
||||||
|
|
||||||
|
@@ -811,6 +811,14 @@ bool SessionNode::showInSimpleTree() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionNode::projectDisplayNameChanged(Node *node)
|
||||||
|
{
|
||||||
|
foreach (NodesWatcher *watcher, m_watchers)
|
||||||
|
emit watcher->nodeSortKeyAboutToChange(node);
|
||||||
|
foreach (NodesWatcher *watcher, m_watchers)
|
||||||
|
emit watcher->nodeSortKeyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
QList<ProjectNode*> SessionNode::projectNodes() const
|
QList<ProjectNode*> SessionNode::projectNodes() const
|
||||||
{
|
{
|
||||||
return m_projectNodes;
|
return m_projectNodes;
|
||||||
|
@@ -301,6 +301,7 @@ public:
|
|||||||
bool isEnabled() const { return true; }
|
bool isEnabled() const { return true; }
|
||||||
|
|
||||||
bool showInSimpleTree() const;
|
bool showInSimpleTree() const;
|
||||||
|
void projectDisplayNameChanged(Node *node);
|
||||||
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);
|
||||||
|
@@ -54,6 +54,7 @@ using namespace ProjectExplorer::Internal;
|
|||||||
|
|
||||||
ProjectWindow::ProjectWindow(QWidget *parent)
|
ProjectWindow::ProjectWindow(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
|
m_ignoreChange(false),
|
||||||
m_currentWidget(0)
|
m_currentWidget(0)
|
||||||
{
|
{
|
||||||
// Setup overall layout:
|
// Setup overall layout:
|
||||||
@@ -82,7 +83,7 @@ ProjectWindow::ProjectWindow(QWidget *parent)
|
|||||||
this, SLOT(startupProjectChanged(ProjectExplorer::Project*)));
|
this, SLOT(startupProjectChanged(ProjectExplorer::Project*)));
|
||||||
|
|
||||||
connect(sessionManager, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
|
connect(sessionManager, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
|
||||||
this, SLOT(projectUpdated(ProjectExplorer::Project*)));
|
this, SLOT(projectDisplayNameChanged(ProjectExplorer::Project*)));
|
||||||
|
|
||||||
// Update properties to empty project for now:
|
// Update properties to empty project for now:
|
||||||
showProperties(-1, -1);
|
showProperties(-1, -1);
|
||||||
@@ -117,31 +118,63 @@ void ProjectWindow::projectUpdated(Project *p)
|
|||||||
m_tabWidget->setCurrentIndex(index);
|
m_tabWidget->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList ProjectWindow::tabDisplayNamesFor(Project *project)
|
||||||
|
{
|
||||||
|
QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<IProjectPanelFactory>();
|
||||||
|
Utils::sort(factories, &IProjectPanelFactory::prioritySort);
|
||||||
|
QStringList subTabs;
|
||||||
|
foreach (IProjectPanelFactory *panelFactory, factories) {
|
||||||
|
if (panelFactory->supports(project))
|
||||||
|
subTabs << panelFactory->displayName();
|
||||||
|
}
|
||||||
|
return subTabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ProjectWindow::insertPosFor(Project *project)
|
||||||
|
{
|
||||||
|
int newIndex = -1;
|
||||||
|
for (int i = 0; i <= m_tabIndexToProject.count(); ++i) {
|
||||||
|
if (i == m_tabIndexToProject.count() ||
|
||||||
|
m_tabIndexToProject.at(i)->displayName() > project->displayName()) {
|
||||||
|
newIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectWindow::projectDisplayNameChanged(Project *project)
|
||||||
|
{
|
||||||
|
int index = m_tabIndexToProject.indexOf(project);
|
||||||
|
if (index < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_ignoreChange = true;
|
||||||
|
bool isCurrentIndex = m_tabWidget->currentIndex() == index;
|
||||||
|
int subIndex = m_tabWidget->currentSubIndex();
|
||||||
|
QStringList subTabs = m_tabWidget->subTabs(index);
|
||||||
|
m_tabIndexToProject.removeAt(index);
|
||||||
|
m_tabWidget->removeTab(index);
|
||||||
|
|
||||||
|
int newIndex = insertPosFor(project);
|
||||||
|
m_tabIndexToProject.insert(newIndex, project);
|
||||||
|
m_tabWidget->insertTab(newIndex, project->displayName(), project->projectFilePath().toString(), subTabs);
|
||||||
|
|
||||||
|
if (isCurrentIndex)
|
||||||
|
m_tabWidget->setCurrentIndex(newIndex, subIndex);
|
||||||
|
m_ignoreChange = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectWindow::registerProject(ProjectExplorer::Project *project)
|
void ProjectWindow::registerProject(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
if (!project || m_tabIndexToProject.contains(project))
|
if (!project || m_tabIndexToProject.contains(project))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// find index to insert:
|
// find index to insert:
|
||||||
int index = -1;
|
int index = insertPosFor(project);
|
||||||
for (int i = 0; i <= m_tabIndexToProject.count(); ++i) {
|
|
||||||
if (i == m_tabIndexToProject.count() ||
|
|
||||||
m_tabIndexToProject.at(i)->displayName() > project->displayName()) {
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList subtabs;
|
|
||||||
|
|
||||||
// Add the project specific pages
|
// Add the project specific pages
|
||||||
QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<IProjectPanelFactory>();
|
QStringList subtabs = tabDisplayNamesFor(project);
|
||||||
Utils::sort(factories, &IProjectPanelFactory::prioritySort);
|
|
||||||
foreach (IProjectPanelFactory *panelFactory, factories) {
|
|
||||||
if (panelFactory->supports(project))
|
|
||||||
subtabs << panelFactory->displayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_tabIndexToProject.insert(index, project);
|
m_tabIndexToProject.insert(index, project);
|
||||||
m_tabWidget->insertTab(index, project->displayName(), project->projectFilePath().toString(), subtabs);
|
m_tabWidget->insertTab(index, project->displayName(), project->projectFilePath().toString(), subtabs);
|
||||||
|
|
||||||
@@ -171,6 +204,9 @@ void ProjectWindow::startupProjectChanged(ProjectExplorer::Project *p)
|
|||||||
|
|
||||||
void ProjectWindow::showProperties(int index, int subIndex)
|
void ProjectWindow::showProperties(int index, int subIndex)
|
||||||
{
|
{
|
||||||
|
if (m_ignoreChange)
|
||||||
|
return;
|
||||||
|
|
||||||
if (index < 0 || index >= m_tabIndexToProject.count()) {
|
if (index < 0 || index >= m_tabIndexToProject.count()) {
|
||||||
removeCurrentWidget();
|
removeCurrentWidget();
|
||||||
return;
|
return;
|
||||||
|
@@ -61,6 +61,7 @@ public slots:
|
|||||||
void projectUpdated(ProjectExplorer::Project *p);
|
void projectUpdated(ProjectExplorer::Project *p);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void projectDisplayNameChanged(ProjectExplorer::Project *p);
|
||||||
void showProperties(int index, int subIndex);
|
void showProperties(int index, int subIndex);
|
||||||
void registerProject(ProjectExplorer::Project*);
|
void registerProject(ProjectExplorer::Project*);
|
||||||
bool deregisterProject(ProjectExplorer::Project*);
|
bool deregisterProject(ProjectExplorer::Project*);
|
||||||
@@ -69,7 +70,10 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void removeCurrentWidget();
|
void removeCurrentWidget();
|
||||||
|
static QStringList tabDisplayNamesFor(Project *project);
|
||||||
|
int insertPosFor(Project *project);
|
||||||
|
|
||||||
|
bool m_ignoreChange;
|
||||||
DoubleTabWidget *m_tabWidget;
|
DoubleTabWidget *m_tabWidget;
|
||||||
QStackedWidget *m_centralWidget;
|
QStackedWidget *m_centralWidget;
|
||||||
QWidget *m_currentWidget;
|
QWidget *m_currentWidget;
|
||||||
|
@@ -992,11 +992,7 @@ void SessionManager::projectDisplayNameChanged()
|
|||||||
if (ProjectExplorerPlugin::currentProject() == pro)
|
if (ProjectExplorerPlugin::currentProject() == pro)
|
||||||
currentNode = ProjectExplorerPlugin::instance()->currentNode();
|
currentNode = ProjectExplorerPlugin::instance()->currentNode();
|
||||||
|
|
||||||
// Fix node sorting
|
d->m_sessionNode->projectDisplayNameChanged(pro->rootProjectNode());
|
||||||
QList<ProjectNode *> nodes;
|
|
||||||
nodes << pro->rootProjectNode();
|
|
||||||
d->m_sessionNode->removeProjectNodes(nodes);
|
|
||||||
d->m_sessionNode->addProjectNodes(nodes);
|
|
||||||
|
|
||||||
if (currentNode)
|
if (currentNode)
|
||||||
ProjectExplorerPlugin::instance()->setCurrentNode(currentNode);
|
ProjectExplorerPlugin::instance()->setCurrentNode(currentNode);
|
||||||
|
Reference in New Issue
Block a user