Fix bugtracker #95: collections pane shows "Untitled project" for a titleless project

The root of a project's embedded collection showed "Projet sans titre"
whenever the project had no title, while the project panel shows the
file name. Fall back to the file name the same way, and only use
"Projet sans titre" for a project that has neither.

The name was also computed once, so changing the project title or saving
it under a new name left the pane stale until the collections were
reloaded. Update it on projectTitleChanged and projectFilePathChanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-25 17:24:17 +12:00
parent 988357057f
commit 3a45625d69
4 changed files with 44 additions and 4 deletions
@@ -21,6 +21,8 @@
#include "../qetproject.h"
#include "xmlelementcollection.h"
#include <QFileInfo>
/**
@brief XmlProjectElementCollectionItem::XmlProjectElementCollectionItem
Constructor
@@ -58,10 +60,7 @@ QString XmlProjectElementCollectionItem::localName()
return text();
if (isCollectionRoot()) {
if (m_project->title().isEmpty())
setText(QObject::tr("Projet sans titre"));
else
setText(m_project->title());
updateProjectName();
}
else {
ElementsLocation location (embeddedPath(), m_project);
@@ -71,6 +70,25 @@ QString XmlProjectElementCollectionItem::localName()
return text();
}
/**
@brief XmlProjectElementCollectionItem::updateProjectName
Set the displayed name of the collection root from the project :
its title, or its file name when it has no title, like the project panel.
Does nothing if this item is not the root of the collection.
*/
void XmlProjectElementCollectionItem::updateProjectName()
{
if (!isCollectionRoot() || !m_project)
return;
if (!m_project->title().isEmpty())
setText(m_project->title());
else if (!m_project->filePath().isEmpty())
setText(QFileInfo(m_project->filePath()).completeBaseName());
else
setText(QObject::tr("Projet sans titre"));
}
/**
@brief XmlProjectElementCollectionItem::name
@return The collection name of this item