From: Stefan Schimanski Date: Mon, 3 Mar 2008 15:10:48 +0000 (+0000) Subject: * fix assert with 4.2.x when setting a null item delegate on an item view. X-Git-Tag: 1.6.10~5926 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7406991fd4ed219a160912986b20eb4908c319c1;p=features.git * 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 --- diff --git a/src/frontends/qt4/GuiCompleter.cpp b/src/frontends/qt4/GuiCompleter.cpp index 1456fe9f4d..a56df94e46 100644 --- a/src/frontends/qt4/GuiCompleter.cpp +++ b/src/frontends/qt4/GuiCompleter.cpp @@ -46,16 +46,27 @@ public: 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_; }; @@ -179,7 +190,8 @@ GuiCompleter::GuiCompleter(GuiWorkArea * gui, QObject * parent) 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); @@ -437,7 +449,7 @@ void GuiCompleter::updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate // 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);