]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiCompleter.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiCompleter.cpp
index 928c27bc93a1055fa50f0aa1f2abbef33fbcb996..c22eaa0fb3c3fa582537f57ca019ef887c441b92 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "Buffer.h"
 #include "BufferView.h"
+#include "CompletionList.h"
 #include "Cursor.h"
 #include "Dimension.h"
 #include "FuncRequest.h"
@@ -23,6 +24,7 @@
 #include "Paragraph.h"
 #include "version.h"
 
+#include "support/assert.h"
 #include "support/debug.h"
 
 #include <QApplication>
@@ -40,10 +42,12 @@ using namespace lyx::support;
 namespace lyx {
 namespace frontend {
 
-class RtlItemDelegate : public QItemDelegate {
+class RtlItemDelegate : public QItemDelegate
+{
 public:
-       explicit RtlItemDelegate(QObject * parent = 0)
-               : QItemDelegate(parent), enabled_(false) {}
+       explicit RtlItemDelegate(QObject * parent)
+               : QItemDelegate(parent), enabled_(false)
+       {}
 
        void setEnabled(bool enabled = true)
        {
@@ -51,7 +55,7 @@ public:
        }
        
 protected:
-       virtual void drawDisplay(QPainter * painter,
+       void drawDisplay(QPainter * painter,
                QStyleOptionViewItem const & option,
                QRect const & rect, QString const & text) const
        {
@@ -71,10 +75,12 @@ private:
 };
 
 
-class PixmapItemDelegate : public QItemDelegate {
+class PixmapItemDelegate : public QItemDelegate
+{
 public:
-       explicit PixmapItemDelegate(QObject *parent = 0)
-       : QItemDelegate(parent) {}
+       explicit PixmapItemDelegate(QObject * parent)
+               : QItemDelegate(parent)
+       {}
 
 protected:
        void paint(QPainter *painter, const QStyleOptionViewItem &option,
@@ -99,22 +105,21 @@ protected:
 };
 
 
-class GuiCompletionModel : public QAbstractListModel {
+class GuiCompletionModel : public QAbstractListModel
+{
 public:
        ///
-       GuiCompletionModel(QObject * parent,
-               Inset::CompletionList const * l)
-               : QAbstractListModel(parent), list_(l) {}
+       GuiCompletionModel(QObject * parent, CompletionList const * l)
+               : QAbstractListModel(parent), list_(l)
+       {}
        ///
-       ~GuiCompletionModel()
-               { delete list_; }
+       ~GuiCompletionModel() { delete list_; }
        ///
        bool sorted() const
        {
                if (list_)
                        return list_->sorted();
-               else
-                       return false;
+               return false;
        }
        ///
        int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const
@@ -144,7 +149,8 @@ public:
                    
                if (index.column() == 0)
                        return toqstr(list_->data(index.row()));
-               else if (index.column() == 1) {
+
+               if (index.column() == 1) {
                        // get icon from cache
                        QPixmap scaled;
                        QString const name = ":" + toqstr(list_->icon(index.row()));
@@ -165,8 +171,8 @@ public:
        }
 
 private:
-       ///
-       Inset::CompletionList const * list_;
+       /// owned by us
+       CompletionList const * list_;
 };
 
 
@@ -480,7 +486,7 @@ void GuiCompleter::updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate
        rtlItemDelegate_->setEnabled(rtl);
 
        // set new model
-       Inset::CompletionList const * list = cur.inset().createCompletionList(cur);
+       CompletionList const * list = cur.inset().createCompletionList(cur);
        setModel(new GuiCompletionModel(this, list));
        modelActive_ = true;
        if (list->sorted())
@@ -525,7 +531,7 @@ void GuiCompleter::showPopup(Cursor & cur)
 }
 
 
-void GuiCompleter::hidePopup(Cursor & cur)
+void GuiCompleter::hidePopup(Cursor &)
 {
        popupVisible_ = false;
 
@@ -573,7 +579,7 @@ void GuiCompleter::hideInline(Cursor & cur)
        // Trigger asynchronous part of hideInline. We might be
        // in a dispatcher here and the setModel call might
        // trigger focus events which is are not healthy here.
-       QTimer::singleShot(0, this, SLOT(asyncHideModel()));
+       QTimer::singleShot(0, this, SLOT(asyncHideInline()));
 
        // mark that the asynchronous part will reset the model
        if (!popupVisible())
@@ -786,7 +792,7 @@ void GuiCompleter::setCurrentCompletion(QString const & s)
                        i = n;
                else
                        i = l;
-               BOOST_ASSERT(0 <= i && i <= n);
+               LASSERT(i <= n, /**/);
        }
 
        // select the first if none was found