goldendict-ng/src/delegate.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
674 B
C++
Raw Normal View History

2022-02-27 05:17:37 +00:00
#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 opt = option;
initStyleOption( &opt, index );
if ( opt.text.isRightToLeft() ) {
opt.direction = Qt::RightToLeft;
}
else {
opt.direction = Qt::LeftToRight;
}
mainDelegate->paint( painter, opt, index );
}