]> 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 0f9686ad6075269dabf28c9c453be35731af3acd..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>
@@ -136,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);
@@ -391,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());
@@ -787,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