mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-21 14:34:13 +02:00
fix(collection): isCustomCollection() false-positive on company path
The default user-collection path ends in "elements" and the default
company-collection path ends in "elements-company". Both
FileElementCollectionItem::isCustomCollection() and
ElementsLocation::isCustomCollection() used startsWith(customDir),
so "…/elements-company/…" matched "…/elements" and returned true.
This caused ElementsCollectionModel::addLocation() to insert a
newly-saved user-collection element as a child of the company-
collection branch in the tree, making it appear in the wrong panel.
Fix: require the path to equal the directory root exactly, or to
start with the directory root followed by '/'.
path == dir || path.startsWith(dir + QLatin1Char('/'))
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -523,7 +523,9 @@ bool ElementsLocation::isCompanyCollection() const
|
||||
*/
|
||||
bool ElementsLocation::isCustomCollection() const
|
||||
{
|
||||
return fileSystemPath().startsWith(QETApp::customElementsDirN());
|
||||
const QString dir = QETApp::customElementsDirN();
|
||||
const QString path = fileSystemPath();
|
||||
return path == dir || path.startsWith(dir + QLatin1Char('/'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -274,7 +274,9 @@ bool FileElementCollectionItem::isCompanyCollection() const
|
||||
*/
|
||||
bool FileElementCollectionItem::isCustomCollection() const
|
||||
{
|
||||
return fileSystemPath().startsWith(QETApp::customElementsDirN());
|
||||
const QString dir = QETApp::customElementsDirN();
|
||||
const QString path = fileSystemPath();
|
||||
return path == dir || path.startsWith(dir + QLatin1Char('/'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user