forked from qt-creator/qt-creator
QmlDesigner.Navigator: Long text in items' names is elided
This commit is contained in:
@@ -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)
|
|||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user