explicit RtlItemDelegate(QObject * parent = 0)
: QItemDelegate(parent) {}
+ void setEnabled(bool enabled = true)
+ {
+ enabled_ = enabled;
+ }
+
protected:
virtual void drawDisplay(QPainter * painter,
QStyleOptionViewItem const & option,
QRect const & rect, QString const & text) const
{
+ if (!enabled_)
+ return QItemDelegate::drawDisplay(painter, option, rect, text);
+
// FIXME: do this more elegantly
docstring stltext = qstring_to_ucs4(text);
reverse(stltext.begin(), stltext.end());
QItemDelegate::drawDisplay(painter, option, rect, toqstr(stltext));
}
+
+private:
+ bool enabled_;
};
setPopup(listView);
popup()->setItemDelegateForColumn(1, new PixmapItemDelegate(this));
rtlItemDelegate_ = new RtlItemDelegate(this);
-
+ popup()->setItemDelegateForColumn(0, rtlItemDelegate_);
+
// create timeout timers
popup_timer_.setSingleShot(true);
inline_timer_.setSingleShot(true);
// turn the direction of the strings in the popup.
// Qt does not do that itself.
- popup()->setItemDelegateForColumn(0, rtl ? rtlItemDelegate_ : 0);
+ rtlItemDelegate_->setEnabled(rtl);
// set new model
Inset::CompletionList const * list = cur.inset().createCompletionList(cur);