]> git.lyx.org Git - features.git/commitdiff
* fix assert with 4.2.x when setting a null item delegate on an item view.
authorStefan Schimanski <sts@lyx.org>
Mon, 3 Mar 2008 15:10:48 +0000 (15:10 +0000)
committerStefan Schimanski <sts@lyx.org>
Mon, 3 Mar 2008 15:10:48 +0000 (15:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23414 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiCompleter.cpp

index 1456fe9f4d354a041fe65d66f7e4078720af5c6f..a56df94e464d2175fa659c6f2d821b102e3a1169 100644 (file)
@@ -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);