Commit 06010713 authored by Konstantin Tokarev's avatar Konstantin Tokarev Committed by Daniel Teske

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

Change-Id: I94386102609772897c93a26ce97acb21d155bdf6
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 60ecbc34
......@@ -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*)));
......
......@@ -75,6 +75,7 @@ public:
private slots:
void addProject(ProjectExplorer::Project *project);
void removeProject(ProjectExplorer::Project *project);
void projectDisplayNameChanged(ProjectExplorer::Project *project);
void changeStartupProject(ProjectExplorer::Project *project);
void setProject(int index);
private:
......
......@@ -119,6 +119,7 @@ public:
virtual void configureAsExampleProject(const QStringList &platforms);
signals:
void displayNameChanged();
void fileListChanged();
// Note: activeTarget can be 0 (if no targets are defined).
......
......@@ -356,6 +356,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
connect(d->m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
this, SLOT(startupProjectChanged()));
connect(d->m_session, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
this, SLOT(projectDisplayNameChanged(ProjectExplorer::Project*)));
connect(d->m_session, SIGNAL(dependencyChanged(ProjectExplorer::Project*,ProjectExplorer::Project*)),
this, SLOT(updateActions()));
connect(d->m_session, SIGNAL(sessionLoaded(QString)),
......@@ -2153,6 +2155,12 @@ void ProjectExplorerPlugin::projectRemoved(ProjectExplorer::Project * pro)
this, SLOT(updateActions()));
}
void ProjectExplorerPlugin::projectDisplayNameChanged(Project *pro)
{
addToRecentProjects(pro->document()->fileName(), pro->displayName());
updateActions();
}
void ProjectExplorerPlugin::startupProjectChanged()
{
static QPointer<Project> previousStartupProject = 0;
......
......@@ -220,6 +220,7 @@ private slots:
void projectAdded(ProjectExplorer::Project *pro);
void projectRemoved(ProjectExplorer::Project *pro);
void projectDisplayNameChanged(ProjectExplorer::Project *pro);
void startupProjectChanged(); // Calls updateRunAction
void activeTargetChanged();
void activeRunConfigurationChanged();
......
......@@ -652,7 +652,6 @@ void FlatModel::removed(FolderNode* parentNode, const QList<Node*> &newNodeList)
QList<Node *>::const_iterator oldIter = oldNodeList.constBegin();
QList<Node *>::const_iterator newIter = newNodeList.constBegin();
Q_ASSERT(isSorted(oldNodeList));
Q_ASSERT(isSorted(newNodeList));
QSet<Node *> emptyDifference;
......
......@@ -252,6 +252,9 @@ ProjectWindow::ProjectWindow(QWidget *parent)
connect(session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
this, SLOT(startupProjectChanged(ProjectExplorer::Project*)));
connect(session, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
this, SLOT(projectUpdated(ProjectExplorer::Project*)));
// Update properties to empty project for now:
showProperties(-1, -1);
}
......
......@@ -82,7 +82,10 @@ public:
void aboutToShutdown();
void extensionsInitialized();
public slots:
void projectUpdated(ProjectExplorer::Project *p);
private slots:
void targetFactoriesChanged();
void showProperties(int index, int subIndex);
......
......@@ -274,6 +274,9 @@ void SessionManager::addProjects(const QList<Project*> &projects)
connect(pro, SIGNAL(fileListChanged()),
this, SLOT(clearProjectFileCache()));
connect(pro, SIGNAL(displayNameChanged()),
this, SLOT(projectDisplayNameChanged()));
if (debug)
qDebug() << "SessionManager - adding project " << pro->displayName();
}
......@@ -910,6 +913,27 @@ void SessionManager::sessionLoadingProgress()
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
void SessionManager::projectDisplayNameChanged()
{
Project *pro = qobject_cast<Project*>(sender());
if (pro) {
Node *currentNode = 0;
if (ProjectExplorerPlugin::currentProject() == pro)
currentNode = ProjectExplorerPlugin::instance()->currentNode();
// Fix node sorting
QList<ProjectNode *> nodes;
nodes << pro->rootProjectNode();
m_sessionNode->removeProjectNodes(nodes);
m_sessionNode->addProjectNodes(nodes);
if (currentNode)
ProjectExplorerPlugin::instance()->setCurrentNode(currentNode);
emit projectDisplayNameChanged(pro);
}
}
QStringList ProjectExplorer::SessionManager::projectsForSessionName(const QString &session) const
{
const QString fileName = sessionNameToFileName(session);
......
......@@ -127,7 +127,7 @@ signals:
void projectAdded(ProjectExplorer::Project *project);
void singleProjectAdded(ProjectExplorer::Project *project);
void aboutToRemoveProject(ProjectExplorer::Project *project);
void projectDisplayNameChanged(ProjectExplorer::Project *project);
void projectRemoved(ProjectExplorer::Project *project);
void startupProjectChanged(ProjectExplorer::Project *project);
......@@ -147,6 +147,8 @@ private slots:
void markSessionFileDirty(bool makeDefaultVirginDirty = true);
void sessionLoadingProgress();
void projectDisplayNameChanged();
private:
bool projectContainsFile(Project *p, const QString &fileName) const;
void restoreValues(const Utils::PersistentSettingsReader &reader);
......
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