]> git.lyx.org Git - lyx.git/commitdiff
fix completion painting for RTL (inline completion and completion list)
authorDov Feldstern <dov@lyx.org>
Wed, 4 Jun 2008 19:45:26 +0000 (19:45 +0000)
committerDov Feldstern <dov@lyx.org>
Wed, 4 Jun 2008 19:45:26 +0000 (19:45 +0000)
see http://permalink.gmane.org/gmane.editors.lyx.devel/107923 for an
explanation, though note that this patch is more extensive than the one
attached there

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25118 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiCompleter.cpp
src/rowpainter.cpp

index 386f019575fb869a3dd3102473509880dae4e09c..4b592dcad72961e8f3ed0c4de1aa19f45298442b 100644 (file)
@@ -47,31 +47,18 @@ class CompleterItemDelegate : public QItemDelegate
 {
 public:
        explicit CompleterItemDelegate(QObject * parent)
-               : QItemDelegate(parent), enabled_(false)
+               : QItemDelegate(parent)
        {}
 
        ~CompleterItemDelegate()
        {}
 
-       void setEnabled(bool enabled = true)
-       {
-               enabled_ = enabled;
-       }
-       
 protected:
        void drawDisplay(QPainter * painter,
                QStyleOptionViewItem const & option,
                QRect const & rect, QString const & text) const
        {
-               if (!enabled_) {
-                       QItemDelegate::drawDisplay(painter, option, rect, text);
-                       return;
-               }
-
-               // FIXME: do this more elegantly
-               docstring stltext = qstring_to_ucs4(text);
-               reverse(stltext.begin(), stltext.end());
-               QItemDelegate::drawDisplay(painter, option, rect, toqstr(stltext));
+               QItemDelegate::drawDisplay(painter, option, rect, text);
        }
 
        void paint(QPainter *painter, const QStyleOptionViewItem &option,
@@ -97,9 +84,6 @@ protected:
                drawFocus(painter, opt, option.rect);
                painter->restore();
        }
-
-private:
-       bool enabled_;
 };
 
 class GuiCompletionModel : public QAbstractListModel
@@ -474,20 +458,17 @@ void GuiCompleter::updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate
        if (old.length() == 0)
                old = last_selection_;
 
+
        // set whether rtl
        bool rtl = false;
        if (cur.inTexted()) {
                Paragraph const & par = cur.paragraph();
                Font const font =
-               par.getFontSettings(cur.bv().buffer().params(), cur.pos());
+                       par.getFontSettings(cur.bv().buffer().params(), cur.pos());
                rtl = font.isVisibleRightToLeft();
        }
        popup()->setLayoutDirection(rtl ? Qt::RightToLeft : Qt::LeftToRight);
 
-       // turn the direction of the strings in the popup.
-       // Qt does not do that itself.
-       itemDelegate_->setEnabled(rtl);
-
        // set new model
        CompletionList const * list = cur.inset().createCompletionList(cur);
        model_->setList(list);
index 6cf341016dfcf6f4292e03ff46859c65a1f13ff5..8ef3b6f310a67bcd8a357d554d9250ad766648dc 100644 (file)
@@ -838,8 +838,6 @@ void RowPainter::paintInlineCompletion(Font const & font)
        // right to left?
        if (rtl) {
                swap(s1, s2);
-               reverse(s1.begin(), s1.end());
-               reverse(s2.begin(), s2.end());
                swap(c1, c2);
        }