mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Avoid a complete Toc reset in case when only a toc item update is needed.
* Buffer: new updateTocItem() signal (with Delegates and GuiView associates). * TocBackend: take care of the signal emission instead of the Cursor::checkBufferStructure() * TocModel: new updateTocItem() method. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26636 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
03b652c9b8
commit
7bd33462a0
@ -2158,6 +2158,14 @@ ErrorList & Buffer::errorList(string const & type) const
|
||||
}
|
||||
|
||||
|
||||
void Buffer::updateTocItem(std::string const & type,
|
||||
DocIterator const & dit) const
|
||||
{
|
||||
if (gui_)
|
||||
gui_->updateTocItem(type, dit);
|
||||
}
|
||||
|
||||
|
||||
void Buffer::structureChanged() const
|
||||
{
|
||||
if (gui_)
|
||||
|
@ -420,6 +420,8 @@ public:
|
||||
|
||||
/// This function is called when the buffer is changed.
|
||||
void changed() const;
|
||||
///
|
||||
void updateTocItem(std::string const &, DocIterator const &) const;
|
||||
/// This function is called when the buffer structure is changed.
|
||||
void structureChanged() const;
|
||||
/// This function is called when some parsing error shows up.
|
||||
|
@ -2193,8 +2193,7 @@ void Cursor::recordUndoSelection() const
|
||||
void Cursor::checkBufferStructure()
|
||||
{
|
||||
Buffer const * master = buffer().masterBuffer();
|
||||
if (master->tocBackend().updateItem(*this))
|
||||
master->structureChanged();
|
||||
master->tocBackend().updateItem(*this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,6 +106,8 @@ Toc & TocBackend::toc(string const & type)
|
||||
|
||||
bool TocBackend::updateItem(DocIterator const & dit)
|
||||
{
|
||||
// Inset * inset = dit.paragraph().inInset();
|
||||
// inset->addToToc(dit);
|
||||
if (dit.paragraph().layout().toclevel == Layout::NOT_IN_TOC)
|
||||
return false;
|
||||
|
||||
@ -149,6 +151,7 @@ bool TocBackend::updateItem(DocIterator const & dit)
|
||||
|
||||
const_cast<TocItem &>(*toc_item).str_ = tocstring;
|
||||
|
||||
buffer_->updateTocItem("tableofcontents", dit);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
namespace lyx {
|
||||
|
||||
class Buffer;
|
||||
class DocIterator;
|
||||
class Inset;
|
||||
|
||||
namespace frontend {
|
||||
@ -61,6 +62,8 @@ public:
|
||||
virtual ~GuiBufferDelegate() {}
|
||||
/// This function is called when the buffer structure is changed.
|
||||
virtual void structureChanged() = 0;
|
||||
/// This function is called when the buffer structure has been updated.
|
||||
virtual void updateTocItem(std::string const &, DocIterator const &) = 0;
|
||||
/// This function is called when some parsing error shows up.
|
||||
virtual void errors(std::string const &) = 0;
|
||||
/// This function is called when some message shows up.
|
||||
|
@ -1042,6 +1042,12 @@ void GuiView::errors(string const & error_type)
|
||||
}
|
||||
|
||||
|
||||
void GuiView::updateTocItem(std::string const & type, DocIterator const & dit)
|
||||
{
|
||||
d.toc_models_.updateItem(toqstr(type), dit);
|
||||
}
|
||||
|
||||
|
||||
void GuiView::structureChanged()
|
||||
{
|
||||
d.toc_models_.reset(view());
|
||||
|
@ -106,6 +106,7 @@ public:
|
||||
void resetAutosaveTimers();
|
||||
void errors(std::string const &);
|
||||
void structureChanged();
|
||||
void updateTocItem(std::string const &, DocIterator const &);
|
||||
///@}
|
||||
|
||||
///
|
||||
|
@ -130,6 +130,14 @@ void TocModel::reset()
|
||||
}
|
||||
|
||||
|
||||
void TocModel::updateItem(DocIterator const & dit)
|
||||
{
|
||||
QModelIndex index = modelIndex(dit);
|
||||
TocItem const & toc_item = tocItem(index);
|
||||
model_->setData(index, toqstr(toc_item.str()), Qt::DisplayRole);
|
||||
}
|
||||
|
||||
|
||||
void TocModel::reset(Toc const & toc)
|
||||
{
|
||||
toc_ = &toc;
|
||||
@ -298,6 +306,12 @@ void TocModels::updateBackend() const
|
||||
}
|
||||
|
||||
|
||||
void TocModels::updateItem(QString const & type, DocIterator const & dit)
|
||||
{
|
||||
models_[type]->updateItem(dit);
|
||||
}
|
||||
|
||||
|
||||
void TocModels::reset(BufferView const * bv)
|
||||
{
|
||||
bv_ = bv;
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
///
|
||||
void reset();
|
||||
///
|
||||
void updateItem(DocIterator const & dit);
|
||||
///
|
||||
void clear();
|
||||
///
|
||||
QAbstractItemModel * model();
|
||||
@ -111,6 +113,8 @@ public:
|
||||
///
|
||||
void updateBackend() const;
|
||||
///
|
||||
void updateItem(QString const & type, DocIterator const & dit);
|
||||
///
|
||||
void sort(QString const & type, bool sort_it);
|
||||
///
|
||||
bool isSorted(QString const & type) const;
|
||||
|
Loading…
Reference in New Issue
Block a user