Skip to content
Snippets Groups Projects
Commit 2e1a68b1 authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlDesigner.Navigator: Long text in items' names is elided

parent aec39f55
Branches
Tags
No related merge requests found
...@@ -160,17 +160,8 @@ void IdItemDelegate::paint(QPainter *painter, ...@@ -160,17 +160,8 @@ void IdItemDelegate::paint(QPainter *painter,
// Check text length does not exceed available space // Check text length does not exceed available space
int extraSpace=12+pixmap.width(); int extraSpace=12+pixmap.width();
QFontMetrics metric(painter->fontMetrics()); QFontMetrics fm(option.font);
if (painter->fontMetrics().boundingRect(myString).width() > option.rect.width()-extraSpace) myString = fm.elidedText(myString,Qt::ElideMiddle,option.rect.width()-extraSpace);
{
QString origString(myString);
int cutpoint=origString.length()/2;
while (painter->fontMetrics().boundingRect(myString).width() > option.rect.width()-extraSpace)
{
cutpoint--;
myString = origString.left(cutpoint)+QLatin1String("...")+origString.right(cutpoint);
}
}
painter->drawText(option.rect.bottomLeft()+QPoint(3+pixmap.width(),-8),myString); painter->drawText(option.rect.bottomLeft()+QPoint(3+pixmap.width(),-8),myString);
......
...@@ -90,7 +90,7 @@ void NavigatorView::modelAttached(Model *model) ...@@ -90,7 +90,7 @@ void NavigatorView::modelAttached(Model *model)
treeWidget()->header()->setResizeMode(0, QHeaderView::Stretch); treeWidget()->header()->setResizeMode(0, QHeaderView::Stretch);
treeWidget()->header()->resizeSection(1,26); treeWidget()->header()->resizeSection(1,26);
treeWidget()->setRootIsDecorated(false); treeWidget()->setRootIsDecorated(false);
treeWidget()->setIndentation(40); treeWidget()->setIndentation(20);
#ifdef _LOCK_ITEMS_ #ifdef _LOCK_ITEMS_
treeWidget()->header()->resizeSection(2,20); treeWidget()->header()->resizeSection(2,20);
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment