mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
* 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
This commit is contained in:
parent
6a10c0a9c6
commit
c3bdbe38d7
@ -60,6 +60,7 @@
|
||||
#include "Undo.h"
|
||||
#include "VCBackend.h"
|
||||
#include "version.h"
|
||||
#include "WordList.h"
|
||||
|
||||
#include "insets/InsetBibitem.h"
|
||||
#include "insets/InsetBibtex.h"
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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_;
|
||||
};
|
||||
|
||||
|
@ -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.
|
||||
|
@ -23,6 +23,8 @@ public:
|
||||
///
|
||||
virtual ~MathCompletionList();
|
||||
|
||||
///
|
||||
virtual bool sorted() const { return false; }
|
||||
///
|
||||
virtual size_t size() const;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user