You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
941 B
C++
29 lines
941 B
C++
#include "delegatepathitem.h"
|
|
#include <QPainter>
|
|
#include <QApplication>
|
|
|
|
void DelegatePathItem::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
const QModelIndex &index) const
|
|
{
|
|
if (!index.isValid())
|
|
return;
|
|
|
|
QStyleOptionViewItem opt = option;
|
|
initStyleOption(&opt, index);
|
|
int padding = 3;
|
|
|
|
painter->save();
|
|
painter->setClipRect(opt.rect);
|
|
opt.rect = opt.rect.adjusted(padding, padding, -padding, -padding);
|
|
painter->drawText(opt.rect, Qt::AlignLeft | Qt::AlignVCenter,
|
|
opt.fontMetrics.elidedText(opt.text, Qt::ElideLeft,
|
|
opt.rect.width()));
|
|
painter->restore();
|
|
|
|
opt.rect = option.rect;
|
|
opt.textElideMode = Qt::ElideLeft;
|
|
opt.text = "";
|
|
|
|
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter);
|
|
}
|