mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-13 06:20:28 +00:00
* fix assert with 4.2.x when setting a null item delegate on an item view.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23414 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
45520d7ced
commit
7406991fd4
@ -46,16 +46,27 @@ public:
|
|||||||
explicit RtlItemDelegate(QObject * parent = 0)
|
explicit RtlItemDelegate(QObject * parent = 0)
|
||||||
: QItemDelegate(parent) {}
|
: QItemDelegate(parent) {}
|
||||||
|
|
||||||
|
void setEnabled(bool enabled = true)
|
||||||
|
{
|
||||||
|
enabled_ = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void drawDisplay(QPainter * painter,
|
virtual void drawDisplay(QPainter * painter,
|
||||||
QStyleOptionViewItem const & option,
|
QStyleOptionViewItem const & option,
|
||||||
QRect const & rect, QString const & text) const
|
QRect const & rect, QString const & text) const
|
||||||
{
|
{
|
||||||
|
if (!enabled_)
|
||||||
|
return QItemDelegate::drawDisplay(painter, option, rect, text);
|
||||||
|
|
||||||
// FIXME: do this more elegantly
|
// FIXME: do this more elegantly
|
||||||
docstring stltext = qstring_to_ucs4(text);
|
docstring stltext = qstring_to_ucs4(text);
|
||||||
reverse(stltext.begin(), stltext.end());
|
reverse(stltext.begin(), stltext.end());
|
||||||
QItemDelegate::drawDisplay(painter, option, rect, toqstr(stltext));
|
QItemDelegate::drawDisplay(painter, option, rect, toqstr(stltext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool enabled_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -179,6 +190,7 @@ GuiCompleter::GuiCompleter(GuiWorkArea * gui, QObject * parent)
|
|||||||
setPopup(listView);
|
setPopup(listView);
|
||||||
popup()->setItemDelegateForColumn(1, new PixmapItemDelegate(this));
|
popup()->setItemDelegateForColumn(1, new PixmapItemDelegate(this));
|
||||||
rtlItemDelegate_ = new RtlItemDelegate(this);
|
rtlItemDelegate_ = new RtlItemDelegate(this);
|
||||||
|
popup()->setItemDelegateForColumn(0, rtlItemDelegate_);
|
||||||
|
|
||||||
// create timeout timers
|
// create timeout timers
|
||||||
popup_timer_.setSingleShot(true);
|
popup_timer_.setSingleShot(true);
|
||||||
@ -437,7 +449,7 @@ void GuiCompleter::updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate
|
|||||||
|
|
||||||
// turn the direction of the strings in the popup.
|
// turn the direction of the strings in the popup.
|
||||||
// Qt does not do that itself.
|
// Qt does not do that itself.
|
||||||
popup()->setItemDelegateForColumn(0, rtl ? rtlItemDelegate_ : 0);
|
rtlItemDelegate_->setEnabled(rtl);
|
||||||
|
|
||||||
// set new model
|
// set new model
|
||||||
Inset::CompletionList const * list = cur.inset().createCompletionList(cur);
|
Inset::CompletionList const * list = cur.inset().createCompletionList(cur);
|
||||||
|
Loading…
Reference in New Issue
Block a user