]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiCompleter.cpp
* open popup on complete-accept if there is a completion available
[lyx.git] / src / frontends / qt4 / GuiCompleter.cpp
index 386f019575fb869a3dd3102473509880dae4e09c..a110bb21e046122426108e964daac3a34f2ab6f0 100644 (file)
@@ -47,33 +47,13 @@ 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));
-       }
-
        void paint(QPainter *painter, const QStyleOptionViewItem &option,
                   const QModelIndex &index) const
        {
@@ -97,9 +77,6 @@ protected:
                drawFocus(painter, opt, option.rect);
                painter->restore();
        }
-
-private:
-       bool enabled_;
 };
 
 class GuiCompletionModel : public QAbstractListModel
@@ -478,16 +455,12 @@ void GuiCompleter::updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate
        bool rtl = false;
        if (cur.inTexted()) {
                Paragraph const & par = cur.paragraph();
-               Font const font =
-               par.getFontSettings(cur.bv().buffer().params(), cur.pos());
+               Font const font =
+                       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);
@@ -652,9 +625,9 @@ void GuiCompleter::hideInline()
 void GuiCompleter::activate()
 {
        if (!popupVisible() && !inlineVisible())
-               return;
-
-       popupActivated(currentCompletion());
+               tab();
+       else
+               popupActivated(currentCompletion());
 }
 
 
@@ -907,4 +880,4 @@ void GuiCompleter::popupHighlighted(const QString & completion)
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiCompleter_moc.cpp"
+#include "moc_GuiCompleter.cpp"