forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delegate.cc
30 lines (26 loc) · 823 Bytes
/
delegate.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <QStyleOptionViewItem>
#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
{
QStyleOptionViewItem opt4 = option;
QStyleOptionViewItem opt = option;
initStyleOption( &opt4, index );
if( opt4.text.isRightToLeft() )
{
opt.direction = Qt::RightToLeft;
if( opt4.textElideMode != Qt::ElideNone )
opt.textElideMode = Qt::ElideLeft;
}
else
{
opt.direction = Qt::LeftToRight;
if( opt4.textElideMode != Qt::ElideNone )
opt.textElideMode = Qt::ElideRight;
}
mainDelegate->paint( painter, opt, index );
}