Fixes https://qelectrotech.org/bugtracker/view.php?id=332
localName() set a non-root folder's label only inside the success path of
loading its qet_directory file. If that load failed -- file missing,
malformed, or unopenable because of the Windows path-encoding problem with
accented characters that plc-user diagnosed on the tracker -- nothing was
set at all, and since a fresh item's text() is null the folder rendered
with a completely blank label. That is the reported symptom.
Resolve the name into a local and always fall back to the folder's own
directory name, so the label is never empty whatever went wrong.
The fallback is applied *after* NamesList::name() rather than passed into
it. This matters: name() returns a caller-supplied fallback before it
reaches its "first available translation" step, so passing m_path in would
replace a perfectly good name in some other language with the raw
directory name. A folder named only in French, viewed under an English
locale, previously showed "Accentué" and must keep doing so.
Falling back on its own would then hide the broken file -- the user sees a
plausible name and never learns there is anything to repair. So a folder
whose qet_directory could not be read now says so in its tooltip, naming
the file, above the collection path that tooltip already carried.
Suggested by plc-user on PR #622. The flag is recorded in localName() and
consumed in setUpData(), because setUpData() assigns the tooltip after
localName() runs and would otherwise discard it.
Only a file-level failure is flagged. A readable qet-directory with no
entry for the current language is not an error; NamesList::name() resolves
that itself and no warning is shown.
Verified on a fixture collection of four folders -- valid, malformed,
missing, and one named only in French:
master this patch
fr-only Accentué Accentué (no warning)
malformed <blank> malformed (warning)
no qet_directory <blank> no_file (warning)
valid Valid Folder Valid Folder (no warning)
The element tooltip showed only the collection path - the least useful
string exactly when a long descriptive name is truncated in the tree
(qelectrotech#552). Show instead: localized name, description,
manufacturer and manufacturer reference (each only when set), with the
collection path kept as the last line. Directories and .qetmak entries
keep the plain path tooltip.
Reuses the location/context already parsed right above for the search
index, so no additional file access or parsing.
GUI-verified on a library where every element carries these fields:
hovering an element now shows e.g. name, "Hutschienennetzteil
85-264VAC auf 24VDC, 92W, Schutzklasse II", manufacturer, order number
and path on five lines.
pugi::xml_document::load_file(const char*) calls fopen/fopen_s on Windows,
which uses the ANSI codepage — not UTF-8. This silently fails when the
collection path contains accented characters (é, ü, ñ, …) or is longer
than the narrow-API MAX_PATH limit, leaving the collection panel with no
element names or illustrations.
Switch both call sites to toStdWString().c_str() which invokes the
load_file(const wchar_t*) overload. On Windows pugixml calls _wfopen,
the wide Unicode API that handles all valid Unicode paths. On Linux/macOS
the same overload converts wchar_t to UTF-8 internally and calls fopen,
so behaviour is unchanged on those platforms.
Affected files:
sources/ElementsCollection/fileelementcollectionitem.cpp (qet_directory load)
sources/ElementsCollection/elementslocation.cpp (element .elmt load, both branches)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
Now Qet only use the new embbeded collection (XmlElementCollection).
No need to reload the old element panel for add a new element created by the new element panel
Elements are always imported to the embbeded collection of a project
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4468 bfdf4180-ca20-0410-9c96-a3a8aa849046
new element panel update the content of the item who represent the edited element (pixmap and name)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4399 bfdf4180-ca20-0410-9c96-a3a8aa849046
We must to use elementcollectionhandler instead
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4343 bfdf4180-ca20-0410-9c96-a3a8aa849046