2022-02-27 05:17:37 +00:00
|
|
|
#include <QStyleOptionViewItem>
|
2013-07-06 15:31:31 +00:00
|
|
|
|
|
|
|
#include "delegate.hh"
|
|
|
|
|
|
|
|
WordListItemDelegate::WordListItemDelegate( QAbstractItemDelegate * delegate ) :
|
|
|
|
QStyledItemDelegate()
|
|
|
|
{
|
|
|
|
mainDelegate = static_cast< QStyledItemDelegate * >( delegate );
|
|
|
|
}
|
|
|
|
|
|
|
|
void WordListItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
|
|
|
|
{
|
2018-05-21 15:32:04 +00:00
|
|
|
QStyleOptionViewItem opt4 = option;
|
2021-12-02 13:10:56 +00:00
|
|
|
|
2013-07-06 15:31:31 +00:00
|
|
|
QStyleOptionViewItem opt = option;
|
|
|
|
initStyleOption( &opt4, index );
|
|
|
|
if( opt4.text.isRightToLeft() )
|
2013-09-02 15:47:09 +00:00
|
|
|
{
|
2013-07-06 15:31:31 +00:00
|
|
|
opt.direction = Qt::RightToLeft;
|
2013-09-02 15:47:09 +00:00
|
|
|
if( opt4.textElideMode != Qt::ElideNone )
|
|
|
|
opt.textElideMode = Qt::ElideLeft;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
opt.direction = Qt::LeftToRight;
|
|
|
|
if( opt4.textElideMode != Qt::ElideNone )
|
|
|
|
opt.textElideMode = Qt::ElideRight;
|
|
|
|
}
|
2013-07-06 15:31:31 +00:00
|
|
|
mainDelegate->paint( painter, opt, index );
|
|
|
|
}
|