Update Project's displayName in GUI if it changes after initial load.

Change-Id: I94386102609772897c93a26ce97acb21d155bdf6
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
Konstantin Tokarev
2012-04-16 19:18:26 +04:00
committed by Daniel Teske
parent 60ecbc3443
commit 06010713e2
10 changed files with 87 additions and 2 deletions

View File

@@ -213,6 +213,8 @@ ProjectListWidget::ProjectListWidget(SessionManager *sessionManager, QWidget *pa
this, SLOT(removeProject(ProjectExplorer::Project*)));
connect(m_sessionManager, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
this, SLOT(changeStartupProject(ProjectExplorer::Project*)));
connect(m_sessionManager, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
this, SLOT(projectDisplayNameChanged(ProjectExplorer::Project*)));
connect(this, SIGNAL(currentRowChanged(int)),
this, SLOT(setProject(int)));
}
@@ -294,6 +296,45 @@ void ProjectListWidget::removeProject(Project *project)
}
void ProjectListWidget::projectDisplayNameChanged(Project *project)
{
m_ignoreIndexChange = true;
int oldPos = 0;
bool useFullName = false;
for (int i = 0; i < count(); ++i) {
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
if (p == project) {
oldPos = i;
} else if (p->displayName() == project->displayName()) {
useFullName = true;
item(i)->setText(fullName(p));
}
}
bool isCurrentItem = (oldPos == currentRow());
QListWidgetItem *projectItem = takeItem(oldPos);
QString sortName = fullName(project);
int pos = count();
for (int i = 0; i < count(); ++i) {
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
QString itemSortName = fullName(p);
if (itemSortName > sortName) {
pos = i;
break;
}
}
QString displayName = useFullName ? fullName(project) : project->displayName();
projectItem->setText(displayName);
insertItem(pos, projectItem);
if (isCurrentItem)
setCurrentRow(pos);
m_ignoreIndexChange = false;
}
void ProjectListWidget::setProject(int index)
{
if (m_ignoreIndexChange)
@@ -538,6 +579,8 @@ MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorActi
this, SLOT(projectAdded(ProjectExplorer::Project*)));
connect(m_sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
connect(m_sessionManager, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
this, SLOT(updateActionAndSummary()));
connect(m_listWidgets[TARGET], SIGNAL(changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration*)),
this, SLOT(setActiveTarget(ProjectExplorer::ProjectConfiguration*)));