1 #include <QStyleOptionViewItemV4>
2 
3 #include "delegate.hh"
4 
WordListItemDelegate(QAbstractItemDelegate * delegate)5 WordListItemDelegate::WordListItemDelegate(  QAbstractItemDelegate * delegate  ) :
6 QStyledItemDelegate()
7 {
8   mainDelegate = static_cast< QStyledItemDelegate * >( delegate );
9 }
10 
paint(QPainter * painter,const QStyleOptionViewItem & option,const QModelIndex & index) const11 void WordListItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
12 {
13 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
14   QStyleOptionViewItem opt4 = option;
15 #else
16   QStyleOptionViewItemV4 opt4 = option;
17 #endif
18   QStyleOptionViewItem opt = option;
19   initStyleOption( &opt4, index );
20   if( opt4.text.isRightToLeft() )
21   {
22     opt.direction = Qt::RightToLeft;
23     if( opt4.textElideMode != Qt::ElideNone )
24       opt.textElideMode = Qt::ElideLeft;
25   }
26   else
27   {
28     opt.direction = Qt::LeftToRight;
29     if( opt4.textElideMode != Qt::ElideNone )
30       opt.textElideMode = Qt::ElideRight;
31   }
32   mainDelegate->paint( painter, opt, index );
33 }
34