Remove the magic boolean in getChildren() from the public interface.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35538 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-09-29 13:05:57 +00:00
parent a6d22abf03
commit 5a46224f73
5 changed files with 37 additions and 22 deletions

View File

@ -2292,7 +2292,7 @@ void Buffer::getLanguages(std::set<Language const *> & languages) const
for (ParConstIterator it = par_iterator_begin(); it != end; ++it)
it->getLanguages(languages);
// also children
ListOfBuffers clist = getChildren();
ListOfBuffers clist = getDescendents();
ListOfBuffers::const_iterator cit = clist.begin();
ListOfBuffers::const_iterator const cen = clist.end();
for (; cit != cen; ++cit)
@ -2482,7 +2482,7 @@ ListOfBuffers Buffer::allRelatives() const
{
if (parent())
return masterBuffer()->allRelatives();
return getChildren(/* true */);
return getDescendents();
}
@ -2520,7 +2520,7 @@ bool Buffer::hasChildren() const
}
void Buffer::getChildren(ListOfBuffers & clist, bool grand_children) const
void Buffer::collectChildren(ListOfBuffers & clist, bool grand_children) const
{
// loop over children
Impl::BufferPositionMap::iterator it = d->children_positions.begin();
@ -2534,15 +2534,23 @@ void Buffer::getChildren(ListOfBuffers & clist, bool grand_children) const
clist.push_back(child);
if (grand_children)
// there might be grandchildren
child->getChildren(clist /*, true */);
child->collectChildren(clist, true);
}
}
ListOfBuffers Buffer::getChildren(bool grand_children) const
ListOfBuffers Buffer::getChildren() const
{
ListOfBuffers v;
getChildren(v, grand_children);
collectChildren(v, false);
return v;
}
ListOfBuffers Buffer::getDescendents() const
{
ListOfBuffers v;
collectChildren(v, true);
return v;
}
@ -3430,7 +3438,7 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
} else
errors(error_type);
// also to the children, in case of master-buffer-view
ListOfBuffers clist = getChildren();
ListOfBuffers clist = getDescendents();
ListOfBuffers::const_iterator cit = clist.begin();
ListOfBuffers::const_iterator const cen = clist.end();
for (; cit != cen; ++cit) {

View File

@ -305,14 +305,6 @@ public:
void setParent(Buffer const *);
Buffer const * parent() const;
/// Collect all relative buffers, in the order in which they appear.
/// I.e., the "root" Buffer is first, then its first child, then any
/// of its children, etc. However, there are no duplicates in this
/// list.
/// This is "stable", too, in the sense that it returns the same
/// thing from whichever Buffer it is called.
ListOfBuffers allRelatives() const;
/** Get the document's master (or \c this if this is not a
child document)
*/
@ -324,11 +316,23 @@ public:
/// \return true if this \c Buffer has children
bool hasChildren() const;
/// return a vector of all children (and grandchildren)
ListOfBuffers getChildren(bool grand_children = true) const;
/// \return a list of the direct children of this Buffer.
/// this list has no duplicates and is in the order in which
/// the children appear.
ListOfBuffers getChildren() const;
/// Add all children (and grandchildren) to supplied vector
void getChildren(ListOfBuffers & children, bool grand_children = true) const;
/// \return a list of all descendents of this Buffer (children,
/// grandchildren, etc). this list has no duplicates and is in
/// the order in which the children appear.
ListOfBuffers getDescendents() const;
/// Collect all relative buffers, in the order in which they appear.
/// I.e., the "root" Buffer is first, then its first child, then any
/// of its children, etc. However, there are no duplicates in this
/// list.
/// This is "stable", too, in the sense that it returns the same
/// thing from whichever Buffer it is called.
ListOfBuffers allRelatives() const;
/// Is buffer read-only?
bool isReadonly() const;
@ -606,6 +610,9 @@ private:
/// of loaded child documents).
support::FileNameList const &
getBibfilesCache(UpdateScope scope = UpdateMaster) const;
///
void collectChildren(ListOfBuffers & children, bool grand_children) const;
/// Use the Pimpl idiom to hide the internals.
class Impl;

View File

@ -276,7 +276,7 @@ Buffer * BufferList::getBufferFromTmp(string const & s)
if (suffixIs(s, master_name))
return *it;
// if not, try with the children
ListOfBuffers clist = (*it)->getChildren();
ListOfBuffers clist = (*it)->getDescendents();
ListOfBuffers::const_iterator cit = clist.begin();
ListOfBuffers::const_iterator cend = clist.end();
for (; cit != cend; ++cit) {

View File

@ -3045,7 +3045,7 @@ void GuiDocument::updateIncludeonlys()
masterChildModule->maintainAuxCB->setEnabled(true);
}
QTreeWidgetItem * item = 0;
ListOfBuffers children = buffer().getChildren(false);
ListOfBuffers children = buffer().getChildren();
ListOfBuffers::const_iterator it = children.begin();
ListOfBuffers::const_iterator end = children.end();
bool has_unincluded = false;

View File

@ -2328,7 +2328,7 @@ bool GuiView::closeBuffer(Buffer & buf)
// in the session file in the correct order. If we close the master
// buffer, we can close or release the child buffers here too.
if (!closing_) {
ListOfBuffers clist = buf.getChildren(false);
ListOfBuffers clist = buf.getChildren();
ListOfBuffers::const_iterator it = clist.begin();
ListOfBuffers::const_iterator const bend = clist.end();
for (; it != bend; ++it) {