Angus Leeming a écrit :
Abdelrazak Younes <[EMAIL PROTECTED]> writes:
OK to commit?

Minor points only:

Index: src/frontends/controllers/ControlToc.C
+toc::TocItem const ControlToc::getCurrentTocItem(
+       string const & type) const
+{
+       BufferView const * const bv = kernel().bufferview();
+       if (!bv)
+               return toc::TocItem(-1, -1, "");

If the third parameter to TocItem is a std::string, then pass it a std::string.
No need to initiate a conversion from char const *.

You're right. I see that I am not the only one caring for efficiency ;-)

Index: src/frontends/controllers/ControlToc.h
+       /// Return the first TocItem before the cursor
+       toc::TocItem const getCurrentTocItem(
+               std::string const & type) const;

Perhaps we are using language differently, but to my ears "the first TocItem
after the cursor" sounds more plausible.

No, I really mean "the first TocItem before the cursor". Indeed we want to know which section we're in and the section paragraph is placed _before_ or _at_ the current paragraph.

Unless you really do mean to navigate
from the cursor back towards the beginning of the document.

Yes, and in my current patch I move from the end of the Toc toward the beginning in order to find the relevant TocItem.



Index: src/frontends/qt4/QToc.C
===================================================================

This looks like heavyweight manipulation to get the data you desire. It suggests
that TocItem needs a new member function that should be used instead of 
item.str.

Yes, my first version used a new ParConstIterator member but I really fear the reaction of main developers (Lars in particular ;-)). So, Lars, if you're OK with that I'll add this new member or maybe your new universal paragraph ID if you commit it. Lars?

+QModelIndex const QToc::getCurrentIndex()
+{
+       vector<string> const & types = getTypes();
+       toc::TocItem const item = getCurrentTocItem(types[type_]);
+       if (item.id_ == -1) {
+               lyxerr[Debug::GUI]
+                       << "QToc::getCurrentIndex(): TocItem is invalid!" << 
endl;
+               return QModelIndex();
+       }
+
+       string toc_str = item.str;
+       toc_str.erase(0, toc_str.find(' ') + 1);
+
+       return toc_models_[type_]->index(toc_str);
+}
+
+

One of these days I'm going to have to try out all these exciting new toys ;-)

:-)

Abdel.

Reply via email to