diff --git a/src/Layout.cpp b/src/Layout.cpp index 2efe9edf9f..134d6a1ad9 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -230,9 +230,10 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass) << to_utf8(style) << "'\n" << "All layouts so far:" << endl; - for (size_t i = 0; i != tclass.layoutCount(); ++i) - lyxerr << to_utf8(tclass.layout(i)->name()) - << endl; + DocumentClass::const_iterator lit = tclass.begin(); + DocumentClass::const_iterator len = tclass.end(); + for (; lit != len; ++lit) + lyxerr << to_utf8((*lit)->name()) << endl; //lexrc.printError("Cannot copy known " // "style `$$Token'"); diff --git a/src/Text3.cpp b/src/Text3.cpp index 52f0e0dda6..d434eb5aaf 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -327,8 +327,10 @@ static void outline(OutlineOp mode, Cursor & cur) toclevel = start->layout()->toclevel; if (toclevel == Layout::NOT_IN_TOC) continue; - for (size_t i = 0; i != tc.layoutCount(); ++i) { - LayoutPtr const & lt = tc.layout(i); + DocumentClass::const_iterator lit = tc.begin(); + DocumentClass::const_iterator len = tc.end(); + for (; lit != len; ++lit) { + LayoutPtr const & lt = *lit; if (lt->toclevel == toclevel + 1 && start->layout()->labeltype == lt->labeltype) { start->setLayout(lt); @@ -345,8 +347,10 @@ static void outline(OutlineOp mode, Cursor & cur) toclevel = start->layout()->toclevel; if (toclevel == Layout::NOT_IN_TOC) continue; - for (size_t i = 0; i != tc.layoutCount(); ++i) { - LayoutPtr const & lt = tc.layout(i); + DocumentClass::const_iterator lit = tc.begin(); + DocumentClass::const_iterator len = tc.end(); + for (; lit != len; ++lit) { + LayoutPtr const & lt = *lit; if (lt->toclevel == toclevel - 1 && start->layout()->labeltype == lt->labeltype) { start->setLayout(lt); diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 6342c1f691..dd94d3aa9a 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -531,8 +531,11 @@ bool TextClass::read(FileName const & filename, ReadType rt) min_toclevel_ = Layout::NOT_IN_TOC; max_toclevel_ = Layout::NOT_IN_TOC; - for (size_t i = 0; i != layoutCount(); ++i) { - int const toclevel = layout(i)->toclevel; + DocumentClass::const_iterator lit = begin(); + DocumentClass::const_iterator len = end(); + for (; lit != len; ++lit) { + Layout const & lt = **lit; + int const toclevel = lt.toclevel; if (toclevel != Layout::NOT_IN_TOC) { if (min_toclevel_ == Layout::NOT_IN_TOC) min_toclevel_ = toclevel; diff --git a/src/TextClass.h b/src/TextClass.h index 6e2302db50..e4067ffd20 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -57,6 +57,18 @@ public: typedef std::vector LayoutList; /// The inset layouts available to this class typedef std::map InsetLayouts; + /// + typedef LayoutList::const_iterator const_iterator; + + /////////////////////////////////////////////////////////////////// + // Iterators + /////////////////////////////////////////////////////////////////// + /// Note that this returns a (LayoutPtr *). We really need a custom + /// iterator here. + const_iterator begin() const { return layoutlist_.begin(); } + /// + const_iterator end() const { return layoutlist_.end(); } + /////////////////////////////////////////////////////////////////// // Layout Info @@ -74,8 +86,6 @@ public: { return emptylayout_; } /// Enumerate the paragraph styles. size_t layoutCount() const { return layoutlist_.size(); } - /// Access the paragraph styles. - LayoutPtr const & layout(size_t index) const { return layoutlist_[index]; } /// bool hasLayout(docstring const & name) const; /// diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 3106737407..9d06335869 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -1410,8 +1410,11 @@ void GuiDocument::updateNumbering() QString const no = qt_("No"); QString const yes = qt_("Yes"); QTreeWidgetItem * item = 0; - for (size_t i = 0; i != tclass.layoutCount(); ++i) { - Layout const & lt = *tclass.layout(i); + + DocumentClass::const_iterator lit = tclass.begin(); + DocumentClass::const_iterator len = tclass.end(); + for (; lit != len; ++lit) { + Layout const & lt = **lit; int const toclevel = lt.toclevel; if (toclevel != Layout::NOT_IN_TOC && lt.labeltype == LABEL_COUNTER) { item = new QTreeWidgetItem(numberingModule->tocTW); diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index 8c59d089e3..7c08c161cd 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -628,8 +628,10 @@ void GuiLayoutBox::updateContents(bool reset) text_class_ = text_class; model_->clear(); - for (size_t i = 0; i != text_class_->layoutCount(); ++i) { - Layout const & lt = *text_class_->layout(i); + DocumentClass::const_iterator lit = text_class_->begin(); + DocumentClass::const_iterator len = text_class_->end(); + for (; lit != len; ++lit) { + Layout const & lt = **lit; docstring const & name = lt.name(); // if this inset requires the empty layout, we skip the default // layout