mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-14 06:57:01 +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 "Undo.h"
|
||||||
#include "VCBackend.h"
|
#include "VCBackend.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "WordList.h"
|
||||||
|
|
||||||
#include "insets/InsetBibitem.h"
|
#include "insets/InsetBibitem.h"
|
||||||
#include "insets/InsetBibtex.h"
|
#include "insets/InsetBibtex.h"
|
||||||
|
@ -97,6 +97,14 @@ public:
|
|||||||
~GuiCompletionModel()
|
~GuiCompletionModel()
|
||||||
{ delete list_; }
|
{ delete list_; }
|
||||||
///
|
///
|
||||||
|
bool sorted() const
|
||||||
|
{
|
||||||
|
if (list_)
|
||||||
|
return list_->sorted();
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
///
|
||||||
int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const
|
int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
@ -417,6 +425,10 @@ void GuiCompleter::updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate
|
|||||||
Inset::CompletionList const * list
|
Inset::CompletionList const * list
|
||||||
= cur.inset().createCompletionList(cur);
|
= cur.inset().createCompletionList(cur);
|
||||||
setModel(new GuiCompletionModel(this, list));
|
setModel(new GuiCompletionModel(this, list));
|
||||||
|
if (list->sorted())
|
||||||
|
setModelSorting(QCompleter::CaseSensitivelySortedModel);
|
||||||
|
else
|
||||||
|
setModelSorting(QCompleter::UnsortedModel);
|
||||||
|
|
||||||
// show popup
|
// show popup
|
||||||
if (popupUpdate)
|
if (popupUpdate)
|
||||||
|
@ -303,6 +303,8 @@ public:
|
|||||||
///
|
///
|
||||||
virtual ~CompletionList() {}
|
virtual ~CompletionList() {}
|
||||||
///
|
///
|
||||||
|
virtual bool sorted() const =0;
|
||||||
|
///
|
||||||
virtual size_t size() const =0;
|
virtual size_t size() const =0;
|
||||||
/// returns the string shown in the gui.
|
/// returns the string shown in the gui.
|
||||||
virtual docstring data(size_t idx) const =0;
|
virtual docstring data(size_t idx) const =0;
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "TextClass.h"
|
#include "TextClass.h"
|
||||||
#include "TextMetrics.h"
|
#include "TextMetrics.h"
|
||||||
#include "TexRow.h"
|
#include "TexRow.h"
|
||||||
|
#include "WordList.h"
|
||||||
|
|
||||||
#include "frontends/alert.h"
|
#include "frontends/alert.h"
|
||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
@ -69,26 +70,23 @@ class TextCompletionList : public Inset::CompletionList {
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
TextCompletionList(Cursor const & cur)
|
TextCompletionList(Cursor const & cur)
|
||||||
: buf_(cur.buffer()), it_(buf_.registeredWords().begin()), pos_(0) {}
|
: buf_(cur.buffer()), pos_(0) {}
|
||||||
///
|
///
|
||||||
virtual ~TextCompletionList() {}
|
virtual ~TextCompletionList() {}
|
||||||
|
|
||||||
|
///
|
||||||
|
virtual bool sorted() const { return true; }
|
||||||
///
|
///
|
||||||
virtual size_t size() const {
|
virtual size_t size() const {
|
||||||
return buf_.registeredWords().size();
|
return buf_.registeredWords().size();
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
virtual docstring data(size_t idx) const {
|
virtual docstring data(size_t idx) const {
|
||||||
std::set<docstring>::const_iterator it
|
return buf_.registeredWords().word(idx);
|
||||||
= buf_.registeredWords().begin();
|
|
||||||
for (size_t i = 0; i < idx; ++i)
|
|
||||||
it++;
|
|
||||||
return *it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Buffer const & buf_;
|
Buffer const & buf_;
|
||||||
std::set<docstring>::const_iterator const it_;
|
|
||||||
size_t pos_;
|
size_t pos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,8 +29,6 @@ class Dimension;
|
|||||||
class ParagraphList;
|
class ParagraphList;
|
||||||
class InsetTabular;
|
class InsetTabular;
|
||||||
|
|
||||||
class WordList : public std::set<docstring> {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A text inset is like a TeX box to write full text
|
A text inset is like a TeX box to write full text
|
||||||
(including styles and other insets) in a given space.
|
(including styles and other insets) in a given space.
|
||||||
|
@ -23,6 +23,8 @@ public:
|
|||||||
///
|
///
|
||||||
virtual ~MathCompletionList();
|
virtual ~MathCompletionList();
|
||||||
|
|
||||||
|
///
|
||||||
|
virtual bool sorted() const { return false; }
|
||||||
///
|
///
|
||||||
virtual size_t size() const;
|
virtual size_t size() const;
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user