From: Stefan Schimanski Date: Mon, 25 Feb 2008 01:55:50 +0000 (+0000) Subject: * implemention of the WordList with iterator caching for a std::set string list. X-Git-Tag: 1.6.10~6108 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c3bdbe38d7969a4ce4447bd3003c8657341d6843;p=features.git * implemention of the WordList with iterator caching for a std::set string list. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23210 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 5615355fae..bd6b7f7fc7 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -60,6 +60,7 @@ #include "Undo.h" #include "VCBackend.h" #include "version.h" +#include "WordList.h" #include "insets/InsetBibitem.h" #include "insets/InsetBibtex.h" diff --git a/src/frontends/qt4/GuiCompleter.cpp b/src/frontends/qt4/GuiCompleter.cpp index 47f7b1fbe8..b50b472f34 100644 --- a/src/frontends/qt4/GuiCompleter.cpp +++ b/src/frontends/qt4/GuiCompleter.cpp @@ -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) diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 349220bccc..df78edb5d1 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -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; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index f780c89fc1..453df1558f 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -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::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::const_iterator const it_; size_t pos_; }; diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 9a75d67d36..91c9c75af0 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -29,8 +29,6 @@ class Dimension; class ParagraphList; class InsetTabular; -class WordList : public std::set {}; - /** A text inset is like a TeX box to write full text (including styles and other insets) in a given space. diff --git a/src/mathed/InsetMathNest.h b/src/mathed/InsetMathNest.h index bcdc13afad..fab9f8d9ab 100644 --- a/src/mathed/InsetMathNest.h +++ b/src/mathed/InsetMathNest.h @@ -23,6 +23,8 @@ public: /// virtual ~MathCompletionList(); + /// + virtual bool sorted() const { return false; } /// virtual size_t size() const; ///