]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiCompleter.cpp
Remove special code for Qt5 to manage HiDPI. It's not needed anymore and leads to...
[lyx.git] / src / frontends / qt4 / GuiCompleter.cpp
index 0ed10fa7c116eb0bd9807cf352ed80342b62edb2..0f974f1d97f9016dca9b6b1652a49d23f76ba7e5 100644 (file)
 #include "LyX.h"
 #include "LyXRC.h"
 #include "Paragraph.h"
+#include "qt_helpers.h"
 #include "version.h"
 
 #include "support/lassert.h"
+#include "support/lstrings.h"
+#include "support/debug.h"
 
 #include <QApplication>
 #include <QHeaderView>
@@ -89,9 +92,10 @@ public:
        ~GuiCompletionModel() { delete list_; }
        ///
        void setList(CompletionList const * l) {
+               beginResetModel();
                delete list_;
                list_ = l;
-               reset();
+               endResetModel();
        }
        ///
        bool sorted() const
@@ -134,6 +138,8 @@ public:
                // get icon from cache
                QPixmap scaled;
                QString const name = ":" + toqstr(list_->icon(index.row()));
+               if (name == ":")
+                       return scaled;
                if (!QPixmapCache::find("completion" + name, scaled)) {
                        // load icon from disk
                        QPixmap p = QPixmap(name);
@@ -389,9 +395,9 @@ void GuiCompleter::updateInline(Cursor const & cur, QString const & completion)
        docstring postfix = qstring_to_ucs4(completion.mid(prefix.length()));
        
        // shorten it if necessary
-       if (lyxrc.completion_inline_dots != -1
-           && postfix.size() > unsigned(lyxrc.completion_inline_dots))
-               postfix = postfix.substr(0, lyxrc.completion_inline_dots - 1) + "...";
+       if (lyxrc.completion_inline_dots != -1)
+               support::truncateWithEllipsis(postfix,
+                                                                         unsigned(lyxrc.completion_inline_dots));
 
        // set inline completion at cursor position
        size_t uniqueTo = max(longestUniqueCompletion().size(), prefix.size());
@@ -443,8 +449,8 @@ void GuiCompleter::asyncUpdatePopup()
        // has a bad memory about it and we have to tell him again and again.
        QTreeView * listView = static_cast<QTreeView *>(popup());
        listView->header()->setStretchLastSection(false);
-       listView->header()->setResizeMode(0, QHeaderView::Stretch);
-       listView->header()->setResizeMode(1, QHeaderView::Fixed);
+       setSectionResizeMode(listView->header(), 0, QHeaderView::Stretch);
+       setSectionResizeMode(listView->header(), 1, QHeaderView::Fixed);
        listView->header()->resizeSection(1, 22);
        
        // show/update popup
@@ -785,7 +791,8 @@ void GuiCompleter::setCurrentCompletion(QString const & s)
                        i = n;
                else
                        i = l;
-               LASSERT(i <= n, /**/);
+               // we can try to recover
+               LASSERT(i <= n, i = 0);
        }
 
        // select the first if none was found