fix(ui): add tooltip fallback for truncated tree item names (#193)
Some checks failed
Build and Test / build (pull_request) Has been cancelled

Set tooltips on tree widget items so hovering reveals the full name
when text is truncated by column width. Covers all code paths:
- createNewItem() — initial item creation (columns 0, 1, 2)
- slotChangeObject() — Label and Label2 property updates
- slotNewDocument() — document item creation
- slotRelabelDocument() — document rename

Closes #193
This commit is contained in:
forbes
2026-02-15 03:05:05 -06:00
parent 3de92325a3
commit b60f017363

View File

@@ -3203,6 +3203,7 @@ void TreeWidget::slotNewDocument(const Gui::Document& Doc, bool isMainDoc)
}
item->setIcon(0, *documentPixmap);
item->setText(0, QString::fromUtf8(Doc.getDocument()->Label.getValue()));
item->setToolTip(0, item->text(0));
DocumentMap[&Doc] = item;
}
@@ -3317,7 +3318,9 @@ void TreeWidget::slotRelabelDocument(const Gui::Document& Doc)
{
auto it = DocumentMap.find(&Doc);
if (it != DocumentMap.end()) {
it->second->setText(0, QString::fromUtf8(Doc.getDocument()->Label.getValue()));
auto label = QString::fromUtf8(Doc.getDocument()->Label.getValue());
it->second->setText(0, label);
it->second->setToolTip(0, label);
}
}
@@ -4440,10 +4443,13 @@ bool DocumentItem::createNewItem(
}
assert(item->parent() == parent);
item->setText(0, QString::fromUtf8(data->label.c_str()));
item->setToolTip(0, item->text(0));
if (!data->label2.empty()) {
item->setText(1, QString::fromUtf8(data->label2.c_str()));
item->setToolTip(1, item->text(1));
}
item->setText(2, QString::fromUtf8(data->internalName.c_str()));
item->setToolTip(2, item->text(2));
if (!obj.showInTree() && !showHidden()) {
item->setHidden(true);
}
@@ -4975,6 +4981,7 @@ void TreeWidget::slotChangeObject(const Gui::ViewProviderDocumentObject& view, c
auto displayName = QString::fromUtf8(label);
for (auto item : data->items) {
item->setText(0, displayName);
item->setToolTip(0, displayName);
}
}
}
@@ -4990,6 +4997,7 @@ void TreeWidget::slotChangeObject(const Gui::ViewProviderDocumentObject& view, c
auto displayName = QString::fromUtf8(label);
for (auto item : data->items) {
item->setText(1, displayName);
item->setToolTip(1, displayName);
}
}
}