]> git.lyx.org Git - features.git/commitdiff
Kill indexing into the list of layouts.
authorRichard Heck <rgheck@comcast.net>
Thu, 6 Mar 2008 05:59:21 +0000 (05:59 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 6 Mar 2008 05:59:21 +0000 (05:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23505 a592a061-630c-0410-9148-cb99ea01b6c8

src/Layout.cpp
src/Text3.cpp
src/TextClass.cpp
src/TextClass.h
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiToolbar.cpp

index 2efe9edf9f7cf937ca098ce35bdf8a17107b004e..134d6a1ad96af1ca9524d0aaf689b5617d0e34a4 100644 (file)
@@ -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'");
index 52f0e0dda6a616d6cde70cd5934266a9363244ce..d434eb5aaf25f5029e3e24f53085b7a2013653ba 100644 (file)
@@ -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);
index 6342c1f6914be680ffc8c03874dc599fd1fce9fa..dd94d3aa9a33aba4e1e7983f075832c19272cfab 100644 (file)
@@ -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;
index 6e2302db5071160d879dcf434ff30ef04b78db0d..e4067ffd20eae613f11a764d3f49cd123b39646f 100644 (file)
@@ -57,6 +57,18 @@ public:
        typedef std::vector<LayoutPtr> LayoutList;
        /// The inset layouts available to this class
        typedef std::map<docstring, InsetLayout> 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;
        ///
index 310673740782f9c21f221341d48fd4f345a91d8c..9d0633586977bb207b5f8869ff61a420f5d827bd 100644 (file)
@@ -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);
index 8c59d089e38381bfd410d6772af979c38259eb2a..7c08c161cd29495d84c905a717c976ec82fafafb 100644 (file)
@@ -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