]> git.lyx.org Git - features.git/commitdiff
* implemention of the WordList with iterator caching for a std::set string list.
authorStefan Schimanski <sts@lyx.org>
Mon, 25 Feb 2008 01:55:50 +0000 (01:55 +0000)
committerStefan Schimanski <sts@lyx.org>
Mon, 25 Feb 2008 01:55:50 +0000 (01:55 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23210 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/frontends/qt4/GuiCompleter.cpp
src/insets/Inset.h
src/insets/InsetText.cpp
src/insets/InsetText.h
src/mathed/InsetMathNest.h

index 5615355faedbe5a80e441aab6cb5ac69c931f18e..bd6b7f7fc7c922c4209d4ff9047d33b7f5c392bb 100644 (file)
@@ -60,6 +60,7 @@
 #include "Undo.h"
 #include "VCBackend.h"
 #include "version.h"
+#include "WordList.h"
 
 #include "insets/InsetBibitem.h"
 #include "insets/InsetBibtex.h"
index 47f7b1fbe8c379ff69951d27a458cca247675fd5..b50b472f3466e3058131648c128f49070e7044e4 100644 (file)
@@ -97,6 +97,14 @@ public:
        ~GuiCompletionModel()
                { delete list_; }
        ///
+       bool sorted() const
+       {
+               if (list_)
+                       return list_->sorted();
+               else
+                       return false;
+       }
+       ///
        int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const
        {
                return 2;
@@ -417,6 +425,10 @@ void GuiCompleter::updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate
        Inset::CompletionList const * list
        = cur.inset().createCompletionList(cur);
        setModel(new GuiCompletionModel(this, list));
+       if (list->sorted())
+               setModelSorting(QCompleter::CaseSensitivelySortedModel);
+       else
+               setModelSorting(QCompleter::UnsortedModel);
 
        // show popup
        if (popupUpdate)
index 349220bcccad7b95f41792a7b1a281df7b892d15..df78edb5d1b5314dbe5b2c3c254d1c15e654201e 100644 (file)
@@ -303,6 +303,8 @@ public:
                ///
                virtual ~CompletionList() {}
                ///
+               virtual bool sorted() const =0;
+               ///
                virtual size_t size() const =0;
                /// returns the string shown in the gui.
                virtual docstring data(size_t idx) const =0;
index f780c89fc1f731336a58df5dc363e6f48f231049..453df1558f77d45a5740e2b1401511eb984a0e6c 100644 (file)
@@ -43,6 +43,7 @@
 #include "TextClass.h"
 #include "TextMetrics.h"
 #include "TexRow.h"
+#include "WordList.h"
 
 #include "frontends/alert.h"
 #include "frontends/Painter.h"
@@ -69,26 +70,23 @@ class TextCompletionList : public Inset::CompletionList {
 public:
        ///
        TextCompletionList(Cursor const & cur)
-       : buf_(cur.buffer()), it_(buf_.registeredWords().begin()), pos_(0) {}
+       : buf_(cur.buffer()), pos_(0) {}
        ///
        virtual ~TextCompletionList() {}
 
+       ///
+       virtual bool sorted() const { return true; }
        ///
        virtual size_t size() const {
                return buf_.registeredWords().size();
        }
        ///
        virtual docstring data(size_t idx) const {
-               std::set<docstring>::const_iterator it
-               = buf_.registeredWords().begin();
-               for (size_t i = 0; i < idx; ++i)
-                       it++;
-               return *it;
+               return buf_.registeredWords().word(idx);
        }
 
 private:
        Buffer const & buf_;
-       std::set<docstring>::const_iterator const it_;
        size_t pos_;
 };
 
index 9a75d67d366f756842d0784d2b75a4191f13253d..91c9c75af0450fc9b4a44f1ba427c5d4e6f1448a 100644 (file)
@@ -29,8 +29,6 @@ class Dimension;
 class ParagraphList;
 class InsetTabular;
 
-class WordList : public std::set<docstring> {};
-
 /**
  A text inset is like a TeX box to write full text
  (including styles and other insets) in a given space.
index bcdc13afad565ae627c81c3e5d19b37b994dc6e7..fab9f8d9ab8ee34e02b29404a2c40ca8d50491b0 100644 (file)
@@ -23,6 +23,8 @@ public:
        ///
        virtual ~MathCompletionList();
 
+       ///
+       virtual bool sorted() const { return false; }
        ///
        virtual size_t size() const;
        ///